updating db with csv

Tim Roberts timr at probo.com
Wed Jun 13 07:35:22 CEST 2007


Captain Paralytic <paul_lautman at yahoo.com> wrote:

>On 11 Jun, 07:37, Tim Roberts <t... at probo.com> wrote:
>| Not in standard SQL.  MySQL supports a REPLACE extension that does
>| an UPDATE if the key already exists, and an INSERT if it does not.
>| There is also an extension clause to the INSERT statement called 
>| "ON DUPLICATE KEY UPDATE xxx" that might do what you want.
>
>No Tim, that is not correct. the REPLACE extension does not do an
>update, it does a replace. It delets the old record and inserts a new
>one. The INSERT...ON DUPLICATE KEY UPDATE... does an update. So a
>REPLACE will remove all existing field values not referenced in the
>statement, whilst an INSERT...ON DUPLICATE KEY UPDATE... will preserve
>them. Also REPLACE will make a TIMESTAMP column which has a DEFAULT
>CURRENT_TIMESTAMP setting work like one which has ON UPDATE
>CURRENT_TIMESTAMP DEFAULT CURRENT_TIMESTAMP setting.

Thanks for the correction; that's an important difference.  I'm a Postgres
guy; if I had noticed this was cross-posted to c.d.mysql as well as
comp.lang.python, I probably would have kept quiet.
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list