MySQLdbd error. Perhpas it isn't installed?

rurpy at yahoo.com rurpy at yahoo.com
Wed Mar 27 00:26:06 EDT 2013


On 03/26/2013 03:24 PM, Νίκος Γκρ33κ wrote:> Hello today i deiced to go form python 2.6 to python 3.2.3
> 
> although in 2.6 my script runs in the ht enewest python i ge this error:
> 
> 
> Traceback (most recent call last):
>   File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 171, in execute
>     r = self._query(query)
>   File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 330, in _query
>     rowcount = self._do_query(q)
>   File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 294, in _do_query
>     db.query(q)
> _mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s' at line 1")
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
>   File "metrites.py", line 193, in <module>
>     cur.execute( '''SELECT hits FROM counters WHERE url = %s''', (page,) )
>   File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/cursors.py", line 184, in execute
>     self.errorhandler(self, exc, value)
>   File "/opt/python3/lib/python3.2/site-packages/MySQL_python-1.2.3-py3.2-linux-x86_64.egg/MySQLdb/connections.py", line 36, in defaulterrorhandler
>     raise errorclass(errorvalue)
> _mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%s' at line 1")
> 
> 
> 
> you can also see it at http://superhost.gr
> 
> Any ideas what might be the problem?
> 
> My webhost (hostgator.com) says that The MySQLdb module is already installed for python 3 on this server. 
> 
> Can you please tell me what's the nature of this error?
> 
> Thank you.

This seems to be the problem line of code:

>   File "metrites.py", line 193, in <module>
>     cur.execute( '''SELECT hits FROM counters WHERE url = %s''', (page,) )

If 'page' is not a string as you expect, but is None or (for example)
a list or something else, you might well end up with invalid SQL when
MySQLdb tries to build the executable sql statement.  Sorry I can't 
be more specific -- I haven't used MySQLdb and I'm suggesting what I'd
try for any generic DBI module.

If MySQLdb has a way to turn on debugging so that it prints SQL 
statements before execution, you might want do that.  Then it may be 
obvious what is wrong, or if the SQL still looks ok, try copying it 
and pasting it in a interactive database session to see what error 
occurs.

If not, maybe you can try adding a print statement to your code that
will print the value of 'page'.  This will be easier to do if you 
can run you code interactively.  If you have to run it via a webserver
than maybe you'll need wrap the print output in html commands to make
it visible on the page, or to write it to a file.




More information about the Python-list mailing list