[DB-SIG] PyFormat and execute

Andy Todd andy47 at halfcooked.com
Wed Feb 11 11:41:31 EST 2004

Marc Colosimo wrote:

>> Do not try to do the interpolation yourself: let the database handler do
>> it.
> Hi Danny,
> Wow! Why isn't there a DB FAQ with this in it? I was just using the 
> PyFormat and really didn't understand that the DB-API can handle the 
> interpolation for me. I now understand what the [5] next to the 
> description for execute was describing.
> Does this also escape naughty SQL characters like ' and \ in strings?
> And how can one use the type objects to send NUMBERS, DATETIME objects?
> Thanks,
> Marc

Yes, and yes to your last two questions. It is in the DB-API 
specification, its just not incredibly obvious to the newcomer.

To that end I created a page on the Python Wiki and made this FAQ number 1;


If anyone wants to improve my wording feel free.

 From the desk of Andrew J Todd esq - http://www.halfcooked.com/

More information about the DB-SIG mailing list