executemany ('SELECT ...') (was: [DB-SIG] DBAPI-2.0
clarifications)
brian zimmer
bzimmer@ziclix.com
Mon, 19 Mar 2001 11:32:42 -0600
At 06:14 PM 3/19/2001 +0100, M.-A. Lemburg wrote:
>Note that the original idea behind .nextset() was to allow
>stored procedures to pass back multiple result sets. The idea
>of having .executemany() produce mutliple result sets only came
>up recently on the db-sig list -- I can't really say, that I like
>it...
Really? I do it all the time. Rather than building up a big "in (?, ?,
..., ?)" I create the single "= ?" and pass in the sequence of
sequences. I reuse the prepared statement for each execution and build the
results up for access in .nextset(). I do like it for the reason of
knowing what fetched what and for minimizing having to do:
inclause = "in (%s)" % (",".join(("?",)*len(params)))
I could additionally include the id I'm querying in the result set, but I
already have it. No big deal either way I guess, but I much prefer the
.execute*() for select than building the in list. For what I do I haven't
noticed any performance differences (content management primarily with
Informix) and I like the syntax more.
brian