[DB-SIG] bind parameters

Chris Clark Chris.Clark at actian.com
Thu May 23 23:37:31 CEST 2013


On Thu, 23 May 2013 13:33:20 -0700, Chris Clark 
<Chris.Clark at actian.com> wrote:
> On Thu, 23 May 2013 16:59:27 +0200, M.-A. Lemburg <mal at egenix.com> 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



More information about the DB-SIG mailing list