[DB-SIG] paramstyles (mysql string length?)

Gerhard Häring gh at ghaering.de
Wed Apr 19 17:38:09 CEST 2006


M.-A. Lemburg wrote:
> [...]
> If that's the case, then I suppose supporting qmark style
> wouldn't be too much of a problem.

It's doable, but it requires parsing the SQL, i. e. find all the qmarks 
that are not inside SQL string literals.

Databases like MySQL, PostgreSQL (*) and SQLite 2.x don't natively 
support parameter binding, so the Python adapter will end up quoting 
parameters and stuffing them in the query string.

Which is why these modules just use (py)format now, then they only need 
to quote the parameters appropriately. The rest they get for free from 
Python.

Abolishing (py)format certainly means additional work for the module 
authors. If we do so - I haven't read the whole thread, so I don't know 
what the arguments are for it - then we should include example code in 
the DB-API for parsing qmarks out of ANSI SQL statements.

-- Gerhard

(*) Only in a stupid, nontransparent form.


More information about the DB-SIG mailing list