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

Chris Cogdon chris at cogdon.org
Thu Jun 5 09:19:37 EDT 2003


On Thursday, Jun 5, 2003, at 03:03 US/Pacific, Gerhard Häring wrote:

> M.-A. Lemburg wrote:
>> 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.

My proposal was to have a 'quote' function with exactly the same 
interface as 'execute' which would, just like execute, have the same 
quoting semantics and be able to handle all the same data types. 
Perhaps 'stringize' would be a better name? :)


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




More information about the DB-SIG mailing list