executemany & UPDATE (MySQL & Python)

Nick Arnett narnett at mccmedia.com
Fri Jun 14 14:02:48 EDT 2002


> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Gerhard Häring
> Sent: Friday, June 14, 2002 9:55 AM
> To: python-list at python.org
> Subject: Re: executemany & UPDATE (MySQL & Python)
>
>
> In article <mailman.1024071438.5095.python-list at python.org>, Nick
> Arnett wrote:
> > Can anyone confirm that it is *not* possible to pass a list to
> the Python
> > MySQLdb module in UPDATE operations?
>
> executemany accepts a sequence of sequences, like:
>
> self.dbh.execute("UPDATE Foo SET bla=%s, blorg=%s WHERE snork=%s",
>     [(1,2,3), (4,5,6)])

I know that (obviously, since I'm doing it with INSERTs).  It doesn't seem
to work with UPDATEs, however.  That was my question.  Have you made
something like your example work?

> > Doing the latter with a loop in Python is much slower than I'd
> expect that
> > doing it with a list would be.
>
> For database modules that don't support prepared statements, the db module
> implements executemany with multiple calls to execute, anyway.

Well, since MySQLdb is much faster at inserting that way, I'm assuming that
if it'll do it on an UPDATE, that will also be much faster.

Anyone know if it's supposed to?

Nick






More information about the Python-list mailing list