Sync paramstyle between sqlite and mysql

D

Daniel

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:
'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.
 
D

Daniel

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:


'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
 
J

Jerry Hill

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:

As far as I understand it, paramstyle is informational, not a setting
that you can change. You have no choice but to use the paramstyle
that the provider of the dbapi-compliant module has chosen to use.
 
T

Thorsten Kampe

* Jerry Hill (Tue, 11 Nov 2008 11:24:50 -0500)
As far as I understand it, paramstyle is informational, not a setting
that you can change. You have no choice but to use the paramstyle
that the provider of the dbapi-compliant module has chosen to use.

Right.

Thorsten
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,783
Latest member
RickeyDort

Latest Threads

Top