Sync paramstyle between sqlite and mysql
Daniel
daniel.watrous at gmail.com
Mon Nov 10 13:00:03 EST 2008
Hello,
I'm developing an application that accesses both a MySQL and an SQLite
database. I would like to have named parameters in my SQL and have
found the following:
For MySQL my named parameters need to look like this: %(paramname)s
For SQLite my named parameters need to look like this: :paramname
I have read in PEP249 (http://www.python.org/dev/peps/pep-0249/) that
there are five paramstyles, though it wasn't clear if I should expect
these to be implemented in all DBAPI2 compliant modules. I have found
that I can set the paramstyle, but it doesn't seem to apply:
>>> import sqlite3 as dbapi2
>>> dbapi2.paramstyle
'qmark'
>>> dbapi2.paramstyle = 'format'
>>> dbapi2.paramstyle
'pyformat'
My sqlite access still requires the 'named' format and not
'pyformat'.
Can someone tell me if it's possible to configure a connection or
cursor to use a particular paramstyle?
Thanks.
More information about the Python-list
mailing list