Re: bind parameters
Chris Clark <[email protected]> Thu, 23 May 2013 14:37:31 -0700
| Newsgroups | gmane.comp.python.db |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 23 May 2013 13:33:20 -0700, Chris Clark <[email protected]> wrote: > On Thu, 23 May 2013 16:59:27 +0200, M.-A. Lemburg <[email protected]> wrote: >> On 22.05.2013 00:52, Michael Bayer wrote: >>> As a total aside, I also have issues with some DBAPIs that accept >>> *only* a list for the "sequence", others that accept *only* a tuple >>> (this may be only when the parameter list is empty, however). So >>> specifying the significance of "empty" parameter lists as well as >>> how to test for "sequence" would be nice too, so that I can hit the >>> DBAPI authors with bug reports backed up by the spec. >> The DB-API is already clear on this: any sequence should be >> accepted for .execute() and any sequence of sequences for >> .executemany(). >> >> Spelling out the special case of passing an empty sequence to >> .execute() and .executemany() would probably be wise. For .execute() >> this would only be valid for a statement that doesn't have parameter >> markers. For .executemany() this would be the same as a no-op (and >> only serve a purpose on the basis that it makes writing algorithms >> easier). >> > > I'd like to suggest that if the bind parameter is nonzero (i.e. > __nonzero__ method call) then it is assumed there are no params. This > way we don't have to get into is it an empty sequence, is it None, etc. Apologies, I meant the reverse :-( I'd like to suggest that if the bind parameter is nonzero (i.e. __nonzero__ method call returns True) then it is assumed there *are* params. This way we don't have to get into is it an empty sequence, is it None, etc. Chris _______________________________________________ DB-SIG maillist - [email protected] http://mail.python.org/mailman/listinfo/db-sig