Sync paramstyle between sqlite and mysql

Daniel daniel.watrous at gmail.com
Tue Nov 11 10:56:04 EST 2008


On Nov 10, 11:00 am, Daniel <daniel.watr... at gmail.com> wrote:
> 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.

If no one has any input, can someone tell me where I should post?

Thanks



More information about the Python-list mailing list