The wiki page is somewhat out of date and doesn't really reflect what we've been discussing here on the list recently.
We're currently aiming for making the .paramstyle a user adjustable setting and requiring support for two paramstyles 'qmark' and 'named', while keeping the other paramstyles around to maintain backwards compatibility. An application can then decide which paramstyle to use, which makes porting applications easier. Determining the paramstyle by looking at the parameter type was dropped due to the unreliable nature of using this approach: difficulties in detecting mapping vs. sequence, hiding errors and unclear selection of paramstyle (e.g. numeric vs. qmark vs. format vs. pyformat, or even numeric vs. named). Also note that we've been moving DB-API v2 forward by adding standard extensions to it. The above paramstyle support is likely going to become such an extension. DB-API v3 will then most likely just make some of those extensions mandatory and perhaps add some more details with respect to handling Unicode. Perhaps I should update the page with a summary of what we've been discussing here. On 13.09.2013 19:54, Tony Locke wrote: > Hi, I'm a contributor to the PG8000 Postgres driver: > > https://github.com/mfenniak/pg8000/tree/py3 > > Having read the interesting DBAPI 3.0 wiki page: > > https://wiki.python.org/moin/DbApi3 > > I thought I'd give a suggestion for unified parameters. Apologies if > this has been suggested before, I did have a look at the archives :-) > > In DBAPI 2.0, the parameters to execute() can be a sequence or a > mapping. In DBAPI 3.0, the paramstyle attribute should be removed, and > the style determined by whether the parameters are a sequence or > mapping. For a sequence the 'numeric' style is expected, and for a > mapping the 'named' style. For example: > > execute("select * from emp where name = :1", ['horatio']) > > execute("select * from emp where name = :name", {'name': 'horatio'}) > > The reason I like this solution is that if someone asked me how > parameters work in DBAPI, this one would be the easiest to explain! > > Any thoughts? > > Cheers, > > Tony. > _______________________________________________ > DB-SIG maillist - DB-SIG@python.org > https://mail.python.org/mailman/listinfo/db-sig > -- Marc-Andre Lemburg Director Python Software Foundation http://www.python.org/psf/ _______________________________________________ DB-SIG maillist - DB-SIG@python.org https://mail.python.org/mailman/listinfo/db-sig