[DB-SIG] API 3.0 limiting paramstyle to ['named', 'qmark'] is okay. ('format' is not desirable)

M.-A. Lemburg mal at egenix.com
Fri May 17 17:57:31 CEST 2013

On 17.05.2013 17:44, Vernon D. Cole wrote:
> On Fri, May 17, 2013 at 4:36 PM, M.-A. Lemburg <mal at egenix.com> wrote:
>> e.g. passing a
>> dictionary of parameters to a SQL command which uses a mix
>> of qmark and named style parameter markers.
> That is a plain, simple syntax error, and will be reported as such by the
> SQL engine, along with a million other syntax errors that I have no way of
> detecting in Python.  The error reporting is the same in all cases: "SQL
> does not like your stuff."

Not necessarily, since the database module will likely convert
the SQL to one of the two param styles, so you end up with
a SQL string that contains both the converted param markers
and the ones you had in the original SQL string.

Detecting the used paramstyle from the SQL statement is really
difficult, so modules would more likely used the parameter
object type to determine the paramstyle, but this also has it's

For qmark, you'd look for a sequence, for named, you'd look
for a mapping. There are situations (e.g. in ORMs) where the
parameter object actually supports both interface types.

Which brings us to "In the face of ambiguity, refuse the temptation
to guess." :-)

Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, May 17 2013)
>>> Python Projects, Consulting and Support ...   http://www.egenix.com/
>>> mxODBC.Zope/Plone.Database.Adapter ...       http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
2013-05-07: Released mxODBC Zope DA 2.1.2 ...     http://egenix.com/go46
2013-05-06: Released mxODBC 3.2.3 ...             http://egenix.com/go45

::::: Try our mxODBC.Connect Python Database Interface for free ! ::::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611

More information about the DB-SIG mailing list