When I run this query from a python script using MySQLdb, it throws:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "py_mlb/transactions.py", line 54, in save
db.execute(sql, values)
File "py_mlb/db.py", line 46, in execute
cursor.execute(sql, values)
File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 147, in execute
charset = db.character_set_name()
_mysql_exceptions.InterfaceError: (0, '')
But when I run the query manually in the MySQL monitor, it works fine. Any
ideas here? The python is very simple:
for transaction in self:
values = [None if x == '' else x for x in transaction.values()]
sql = 'REPLACE INTO transaction (%s) VALUES (%s)' % (','.join(transaction.keys()), ','.join(['%s'] * len(values)))
db.execute(sql, values)
db.save()
db being a class that just has a cursor object, which calls execute(sql,
values).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I can't figure out why this is happening. The following query goes into a
UTF8-encoded InnoDB table:
When I run this query from a python script using MySQLdb, it throws:
But when I run the query manually in the MySQL monitor, it works fine. Any
ideas here? The python is very simple:
db being a class that just has a cursor object, which calls execute(sql,
values).