PEP 249 (database api) -- executemany() with iterable?
Roy Smith
roy at panix.com
Tue Oct 12 13:32:35 EDT 2010
On Oct 12, 1:20 pm, Jon Clements <jon... at googlemail.com> wrote:
> On 12 Oct, 16:10, Roy Smith <r... at panix.com> wrote:
>
> > PEP 249 says about executemany():
>
> > Prepare a database operation (query or command) and then
> > execute it against all parameter sequences or mappings
> > found in the sequence seq_of_parameters.
>
> > are there any plans to update the api to allow an iterable instead of
> > a sequence?
>
> I'm not understanding (probably me). Example?
I have a dictionary, d, which has a million items in it, and want to
do something like:
executemany("update foo set bar = %s where id = %s",
d.iteritems())
If executemany accepted an iterable, that would work. But, it only
accepts a sequence, so I need to do:
executemany("update foo set bar = %s where id = %s", d.items())
which generates a million-item temporary list. Or am I mis-
understanding the PEP?
More information about the Python-list
mailing list