Sync paramstyle between sqlite and mysql

Daniel daniel.watrous at
Mon Nov 10 19:00:03 CET 2008


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 ( 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
>>> dbapi2.paramstyle = 'format'
>>> dbapi2.paramstyle

My sqlite access still requires the 'named' format and not

Can someone tell me if it's possible to configure a connection or
cursor to use a particular paramstyle?


More information about the Python-list mailing list