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

Chris Cogdon chris at cogdon.org
Tue Jun 3 19:46:20 EDT 2003


I'm certainly getting a lot more 'aggressive' feedback from this 
proposal than I was expecting. I was hoping for more of a 'good idea', 
or 'good idea, but a lot of work in these circumstances X, Y, Z', or a 
'you're doing it the wrong way, try ABC' instead. Have I really gotten 
on people's nerves so much that they wont even LOOK at the application 
I'm trying to write? Perhaps suggesting alternatives, or something else?

Anyway... I'd like to consolidate some of the arguments I've received:

Doing what I'm proposing with a DMBS that requires pure-string 
statements (like PostgreSQL and MySQL)  is relatively easy, since the 
driver has to quote anyway: making it visible in a standard form is 
little work. However, for databases that handle all the 'binding' on 
the DB site is hard because there's NO current code in the driver that 
does this functionality.

Also, as I understand it, finding the relevant '?' marks (for example) 
in a SQL statement is non-trivial, since '?' may appear in places other 
than binding points (For example, inside a literal string). (Now, I had 
to go figure that one out for myself... someone could have just 
mentioned that).

Because of the above issue, the proposal, useful or not, is 
non-trivial. Perhaps it would be better to write a library that allowed 
piecemeal construction of SQL Statements without binding the parameters 
into the string statement. But, instead, keeping them together until 
being passed into the 'execute' function.

I'll omit the example code for brevity... but I think I could come up 
with something that demonstrates this point nicely. Write me if you 
want to see it.


On other points...

I still maintain that writing code to make a particular DB client 
library meet the DB-API spec *IS* the driver writer's job. Of course 
supplying a quoting function isn't part of that job yet, because it's 
not part of the specification. My proposal was to make the quoting 
function part of the next spec revision and therefore make it the 
driver writers job to get the quoting function correct.

If the difficulty in doing so outweighs the utility of having this 
method, then please... just say so. I think it would be useful, but I 
can see alternatives that are difficult. However, it might not be as 
difficult as supporting quoting for a DMBS that does not currently 
require quoting to support db-api 2.0. If that's the case, then please, 
just say so.


If someone could go through the example applications, the ones that I 
think a quoting method would be useful to use, and suggest another way 
of doing it, or perhaps just saying "do what you were suggesting as an 
alternate; write a few functions to let a string and parameters be 
joined together without quoting" then I would be appreciative.

Regards,


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




More information about the DB-SIG mailing list