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

Andy Dustman farcepest at gmail.com
Fri Apr 21 07:37:06 CEST 2006

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.

The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

More information about the DB-SIG mailing list