[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 19:30:47 CEST 2013

Ok, I think we've heard all sides.

We have two extreme positions:

1. only allow qmark and named, let the driver figure out which one
   is used

2. only allow format/pyformat

and the original idea of having an adjustable paramstyle,
with the only requirement that modules must provide the
two agreed styles qmark and named.

I don't think the extreme positions are going to go anywhere. Both
options break too much code and/or alienate database coders which
are used to the database's native parameter style.

As for how to adjust the paramstyle, I think Vernon's summary
is a good one. SQLAlchemy and other applications could then
do (*):

import dbapi_module
# We want named paramstyle on all connections:
dbapi_module.paramstyle = 'named'

and reduce the overhead of having to escape percent signs.

The automatic paramstyle detection that has been suggested
appears fragile to me, but perhaps it does have some merit.
We could have an 'detect' paramstyle which tells the module
to apply auto-detection of the used style (in whatever way
it chooses). Still, I'm not really convinced this is a
workable approach to solid database programming :-)

Let's think about these things some more over the weekend -
hopefully you all can enjoy some sunshine; it's awfully
cold and rainy in Germany.

(*) I know this contradicts what I wrote to Vernon. After
thinking about it some more, I think the
module level parameter should not go away and may actually
serve a good purpose for defining the overall default of
the module. The DB-API would have to make it clear, though,
that adjusting the module level parameter will only have
an effect on newly created connections.

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