[DB-SIG] pyformat Parameter Style

Chris Cogdon chris at cogdon.org
Sat May 10 11:32:00 EDT 2003


On Saturday, May 10, 2003, at 10:23 US/Pacific, Andy Todd wrote:

> Is there a definitive specification of the pyformat parameter style 
> anywhere?
>
> The usual sources come up dry. It is mentioned in the DB-API 
> specification (http://www.python.org/peps/pep-0249.html) but not 
> defined.
>
> It seems from observation that one should simply put '%(<parameter 
> name>)s' in the query string and then pass a mapping with a 
> corresponding key when calling the execute method. But I'd just like 
> to make absolutely sure.
>
> In particular, I'm curious if the 's' actually means anything (like 
> string?). Should I be using different characters for different data 
> types, and if so, which ones?

You just about nailed it. You should ALWAYS use 's', too, regardless of 
the data type.


-- 
    ("`-/")_.-'"``-._        Chris Cogdon <chris at cogdon.org>
     . . `; -._    )-;-,_`)
    (v_,)'  _  )`-.\  ``-'
   _.- _..-_/ / ((.'
((,.-'   ((,/   fL




More information about the DB-SIG mailing list