[DB-SIG] Optional DB API Extensions

brian zimmer bzimmer@ziclix.com
Fri, 26 Oct 2001 08:48:04 -0500


What's the reasoning behind having .execute and .executemany?  In zxJDBC, I
(apparently erroneously) allow .execute to behave like .executemany.  It
doesn't affect anything functionally and minimizes the client requirement to
check if you have multiple bound parameters, no?

brian

> -----Original Message-----
> From: M.-A. Lemburg [mailto:mal@lemburg.com]
> Sent: Friday, October 26, 2001 7:50 AM
> To: brian zimmer
> Cc: Andy Dustman; DB-SIG @ Python.org
> Subject: Re: [DB-SIG] Optional DB API Extensions
>
>
> brian zimmer wrote:
> >
> > What happens in the case of:
> >
> > cur.execute("insert into x values (?, ?)", [(a, b), (c, d)])
> >
> > I presume the .lastrowid is the value of the insert with (c, d)?
>
> You get a TypeError ;-) .execute() only supports sequence arguments,
> not sequences of sequences. .executemany() is meant for the latter.
>
> Now back to your question:
>
> > What happens in the case of:
> >
> > cur.executemany("insert into x values (?, ?)", [(a, b), (c, d)])
> >
> > I presume the .lastrowid is the value of the insert with (c, d)?
>
> Good Point !
>
> I would presume that too -- except: how do you know that the database
> maintains the order of the arguments that you presented ? Some
> optimizer might feel like adding (a,b) last...
>
> --
> Marc-Andre Lemburg
> CEO eGenix.com Software GmbH
> ______________________________________________________________________
> Consulting & Company:                           http://www.egenix.com/
> Python Software:                        http://www.lemburg.com/python/
>