[DB-SIG] pyformat Parameter Style
Andy Todd
andy47 at halfcooked.com
Thu May 15 10:44:13 EDT 2003
Chris Cogdon wrote:
>
> On Wednesday, May 14, 2003, at 15:24 US/Pacific, Magnus Lyckå wrote:
>
[snip]
>
> No argument here :)
>
> Perhaps the specification should be 'clarified' by writing the following:
>
> """
> To use positional parameter parsing, use '%s' and pass your parameters
> as a tuple as the second parameter to the 'execute' function.
>
> To use keyword parameter parsing, use '%(key)s' and pass your parameters
> as a dictionary as the second parameter to the 'execute' function.
>
> If you need a '%' in your SQL syntax, use '%%'.
>
> This convention operates much like python '%' operator, and may in fact
> be implemented as such. However, the behaviour of using anything other
> than '%s' and '%(key)s' is not defined, and should be avoided. The
> interface is not required to trap for these conditions in this version
> of the specification
> """
>
>
>
+1 to placing that text in the DB-API specification. It makes things
perfectly clear, even to me.
Regards,
Andy
--
--------------------------------------------------------------------------------
From the desk of Andrew J Todd esq - http://www.halfcooked.com/
More information about the DB-SIG
mailing list