[DB-SIG] paramstyle specification

M.-A. Lemburg mal at egenix.com
Tue May 21 21:24:19 CEST 2013

On 21.05.2013 20:55, Michael Bayer wrote:
> On May 21, 2013, at 2:30 PM, M.-A. Lemburg <mal at egenix.com> wrote:
>> Something we do need to address in a paramstyle spec for
>> qmark and named is SQL comments. Perhaps easiest would be
>> to disallow them in SQL statements passed to .execute*().
> um, meaning no SQL comments allowed in a call to cursor.execute() ?   That would be a really big problem for folks who pass comments in their SQL as a means to help with database query log parsing.   There are definitely folks who do that, and it's very useful.

Well, I know it's useful, but it also makes parsing SQL for
parameter markers much harder :-)

>> PS: mxODBC 3.2 implements both styles and does conversion from
>> named to qmark. When choosing named style, we explicitly disallow
>> question marks to appear in the SQL statement to detect errors
>> early and give proper error messages to the user, rather than
>> some obscure "too few parameters for statement".
> you used the word "underspecified" a moment ago which I found frightening, but then three paragraphs later it's just the word I need - I think KISS should be the rule here, the parser is only aware of one paramstyle at a time, and doesn't try to do any nannying of things that look like other paramstyles.   

I'm not sure I understand.

With "underspecified" I meant that we leave the other paramstyles
in the same unspecified state as they are now (or rather leave them
specified by the database module implementations).

For the two main paramstyles we're currently discussing, qmark
and named, we will have to put more effort into specifying
what they mean and how they work.

I agree that adding magic auto-selection of SQL parsers is
not a good idea. If you setup a cursor to expect qmark style,
it should complain loudly when you try to pass in named style
parameters or perhaps even named style SQL.

Marc-Andre Lemburg

Professional Python Services directly from the Source  (#1, May 21 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/

::::: 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