Cannot run a single MySQLdb execute....

Chris Angelico rosuav at gmail.com
Thu Mar 28 05:00:17 CET 2013


On Thu, Mar 28, 2013 at 2:50 PM, Νίκος Γκρ33κ <nikos.gr33k at gmail.com> wrote:
> I'am about to go nuts with python 3.2.3
>
> Do you see somehtign wrong with the following statement?
>
> cur.execute( '''SELECT hits FROM counters WHERE url = ?''', (page,) )
> data = cur.fetchone()
>
> because as you can see by visiting my webpage at http://superhost.gr it produces an error and i dont have  aclue why.
>
> Please help. i'am using MySQLdb

Is this the docs for the module you're using?
http://mysql-python.sourceforge.net/MySQLdb.html
"""
paramstyle
String constant stating the type of parameter marker formatting
expected by the interface. Set to 'format' = ANSI C printf format
codes, e.g. '...WHERE name=%s'. If a mapping object is used for
conn.execute(), then the interface actually uses 'pyformat' = Python
extended format codes, e.g. '...WHERE name=%(name)s'. However, the API
does not presently allow the specification of more than one style in
paramstyle.

Note that any literal percent signs in the query string passed to
execute() must be escaped, i.e. %%.

Parameter placeholders can only be used to insert column values. They
can not be used for other parts of SQL, such as table names,
statements, etc.
"""

What paramstyle are you using?

ChrisA



More information about the Python-list mailing list