[DB-SIG] API 3.0 limiting paramstyle to ['named', 'qmark'] is okay. ('format' is not desirable)
mike_mp at zzzcomputing.com
Fri May 17 17:10:50 CEST 2013
On May 17, 2013, at 11:01 AM, Vernon D. Cole <vernondcole at gmail.com> wrote:
> Good point, the others would be optional.
> How should the switching be done? My present development head has four methods:
> 1) adodbapi.apibase.paramstyle = 'named'
> I think this one should be deprecated. Stepping on a module quasi-constant is never a good idea.
> 2) adodbapi.connect(connection_string, paramstyle='named')
> I just added this one, so a django adapter can hand me a bucketfull of keyword arguments. I think I like this the best in terms of ease-of-use.
> 3) conn = adodbapi.connect(connection_string)
> conn.paramstyle = 'named'
> This is the most obvious, and provides lots of power. The programmer could use 'qmark' to load big INSERT statements, then switch to 'named' for detailed SELECT or UPDATE. The default value is determined by the module author.
> 4) cursor.paramstyle = 'named'
> I have this implemented, but the more I think about it, the more it seems unnecessary.
> What other options should be considered?
My vote is at the module level:
from psycopg2 import dbapi2
from psycopg2 import dbapi3
and if you are using dbapi3, it only supports named and qmark. If you're in dbapi2, then you can have "paramstyle" keywords and all that. I'm hoping for dbapi3 to be more consistent and less switchy.
More information about the DB-SIG