[DB-SIG] API suggestion: expose 'quote' method

Gerhard Häring gh at ghaering.de
Thu Jun 5 13:03:30 EDT 2003

M.-A. Lemburg wrote:
> Magnus Lyckå wrote:
>> At 17:18 2003-06-04 -0700, Chris Cogdon wrote:
>>> So, perhaps what I really should be asking for is to include a 
>>> specification for an interface, such as what I've suggested before, 
>>> but make that a OPTIONAL part of the specification. Ie, if it's easy 
>>> enough to expose, then the driver writers should expose it in the 
>>> standard form.
>>> Does THAT sound reasonable ?
>> Certainly. Many drivers implement things beyond the mandatory
>> standard, and if it's possible to get the extras compatible
>> across drivers, that's a big bonus in my opinion.
> No objection to adding a note to the spec about this. I still
> think that you have to flesh out a reasonable API for this,
> though, e.g. quoting should implemented on a per data type
> basis rather than on a per SQL statement basis.

The pyPgSQL, PySQLite and psycopg developers already agreed on an API 
for the three projects (the newest versions implement this API):

If you want to add support for a new datatype for the DB-API module, 
this data type should implement a __quote__ method that returns the 
appropriate string.

PySQLite and pyPgSQL already have a _quote method like the module-level 
quote method Chris was arguing for. But it's currently only an 
implementation detail, not part of the public APIs.

-- Gerhard<

More information about the DB-SIG mailing list