By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,585 Members | 1,772 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,585 IT Pros & Developers. It's quick & easy.

Sync paramstyle between sqlite and mysql

P: n/a
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.
Nov 10 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Nov 10, 11:00*am, Daniel <daniel.watr...@gmail.comwrote:
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
Nov 11 '08 #2

P: n/a
On Mon, Nov 10, 2008 at 1:00 PM, Daniel <da************@gmail.comwrote:
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.

--
Jerry
Nov 11 '08 #3

P: n/a
* Jerry Hill (Tue, 11 Nov 2008 11:24:50 -0500)
On Mon, Nov 10, 2008 at 1:00 PM, Daniel <da************@gmail.comwrote:
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.
Right.

Thorsten
Nov 11 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.