[DB-SIG] paramstyles, again

Carsten Haese carsten at uniqsys.com
Mon Jun 4 13:17:46 CEST 2007


On Mon, 04 Jun 2007 10:41:46 +0200, M.-A. Lemburg wrote
> > We still need to settle the question of what to do about numeric and
> > named styles. There is some support for making both styles mandatory and
> > expecting the API to automatically discern from the query string which
> > parameter style is in use.
> 
> I don't think that this is such a good idea and I'm also not sure
> how you'd do that: what if a programmer mixes the two (or three)
> styles by mistake ? How would the programmer test whether a
> module supports this automatic detection scheme ?

If the programmer mixes incompatible parameter styles, the implementation can
choose to handle it gracefully (sqlite3) or raise an exception (InformixDB).
InformixDB actually allows mixing qmark and numeric in a straightforward way:
The first question mark is equivalent to :1, the second question mark is
equivalent to :2, etc. Only mixing positional markers and named markers raises
an exception.

I'd be okay with throwing an exception in any case of mixing, but I don't know
how that would sit with sqlite3.

The test for whether the module supports the automatic detection is
module.apilevel=='3.0'.

> There's also the problem of parameter type if we allow named
> style. The parameters would then have to be dictionaries for
> named and tuples for qmark/numeric. So you effectively change
> the signature of the .execute() methods based on a parameter
> which is not good style.

I disagree. It's duck-typing.

--
Carsten Haese
http://informixdb.sourceforge.net



More information about the DB-SIG mailing list