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

Chris Cogdon chris at cogdon.org
Wed Jun 4 18:12:26 EDT 2003


On Wednesday, Jun 4, 2003, at 01:17 US/Pacific, M.-A. Lemburg wrote:

> Even better: the database server can prepare the data access
> paths from the abstract SQL statement and cache that access
> path for subsequent queries -- that's hardly possible if you
> have the arguments quoted and embedded directly into the
> SQL. In the latter case, you'd also lose the DB-API feature
> of caching the last used SQL statement on a database cursor.
>
> Another argument against using embedded data types is that
> of precision loss, e.g. ODBC interfaces C types directly
> to the driver which assures that you don't lose precision
> by converting them to a string representation. This happens
> for Python floats, integers and even date/time values.

All of that is exceptionally useful. But there are circumstances where 
it's MUCH easier for the application to be able to deal with 'string 
only' SQL fragments. Yes, these cases are rare, and there are 
workarounds, making the request of a 'particular DMBS-compatible 
quoting function' non-compulsory. However, that does not mean it does 
not have SOME utility.

If precision-loss is not an issue (perhaps all the required types are 
strings or integers), and performance loss is not an issue (perhaps 
there's more work in using the 'workaround'), then why would this not 
be useful?

Saying "It's too hard for the python driver writer" IS a useful 
argument, and one that I'm not contesting, but that argument has not 
really been used here. Everyone seems to be saying "I don't see why you 
would want this", or "there are disadvantages to this, such as 
performance loss" which can EASILY be argued against by showing you an 
application, and claiming that the performance loss is insignificant in 
comparison to the simplicity of coding in other parts. (after all, 
that's why you'd write a python driver in python rather than C, right?)


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




More information about the DB-SIG mailing list