[DB-SIG] spec: named parameters: clarification needed

Matthew T. Kromer matt@zope.com
Fri, 14 Feb 2003 15:01:35 -0500


M.-A. Lemburg wrote:

> Dittmar, Daniel wrote:
>
>> The spec says about param styles:
>>
>> 'named'         Named style, e.g. '...WHERE name=:name'
>>
>> Does this mean that the driver has to accept dictionaries as the 
>> second argument to cursor.execute ()? Does this mean that driver has 
>> to accept only dictionaries?
>>
>> Stuart's dbapi20.py seems to assume this and I have at least one user 
>> that fell for it as well.
>
>
> Good question. Are there any modules out there actually implementing
> this ?
>
> I see two interpretations here:
>
> 1. .execute() gets a dictionary as parameter
> 2. .execute() gets keywords as parameter
>

I do it in DCOracle2 with the latter, not the former -- I find it more 
intuitive to allow keyword arguments vs. a dictionary as a parameter 
pass.  If the dictionary pass is correct, I'd probably test the arg list 
to see if the only arg was a dictionary, and if the keyword list was 
empty, and if so, assume that the dictionary was the keyword list (I 
don't do this).

However, DCOracle2 advertises numeric parameter notation vs. named so I 
don't worry about it overmuch.