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

M.-A. Lemburg mal at egenix.com
Fri Apr 21 13:30:20 CEST 2006


Andy Dustman wrote:
> On 4/19/06, Gerhard Häring <gh at ghaering.de> wrote:
>> 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.
> 
> -1 on making qmark mandatory, even though I am constantly having to
> correct newbies who see %s and think, "I must use a string formatting
> operator since I am too ignorant to read PEP-249".
> 
> On the other hand, MySQL-4.1 and newer *does* support ? as a
> placeholder *iff* you are using the prepared statement API, which
> MySQLdb does not implement *yet*, but that is one of the next things
> to do. One complication is, not all SQL statements will work with the
> prepared statements API, and there is a lot of code out there that
> correctly uses %s. I am probably going to have to have some means for
> indicating what paramstyle is in use by the application, so the driver
> can transliterate it if it needs to, and that's one of the things I
> have to figure out for MySQLdb-1.3/1.4/2.0.

If we make qmark support mandatory and deprecate pyformat/format
in DB API 2.1 would that be a workable approach ?

I'd say that we schedule DB API 2.1 for later this year with
the main aim of making some of the currently already documented
standard extensions mandatory and maybe adding optional support
for defining type mappings (both input and output).

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Apr 21 2006)
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::


More information about the DB-SIG mailing list