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

M.-A. Lemburg mal at lemburg.com
Thu Jun 5 18:28:50 EDT 2003


Chris Cogdon wrote:
> 
> 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? :)

I'd like to hear some more feedback from other db-sig subscribers.

I personally think that a quote function to generate SQL literals
for various backends available as separate Python module would
go much further than choosing this highly specific kind of interface.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Software directly from the Source  (#1, Jun 05 2003)
 >>> Python/Zope Products & Consulting ...         http://www.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________
EuroPython 2003, Charleroi, Belgium:                        19 days left




More information about the DB-SIG mailing list