I am trying to update the data in a row of MySQL which this line of code is throwing this error.
for k in range(city_count):
cur.execute("UPDATE hqstock SET citylastprice = '%s' WHERE id = '%s'"%(CITYPRICE[k], tID[k]))
The error that was returned:
File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 201, in execute
self.errorhandler(self, exc, value)
File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
InterfaceError: (0, '')
This is my table structure.
+--------------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+------------------+------+-----+---------+-------+
| id |int(11) unsigned | NO | PRI | NULL | |
| barcode | char(15) | YES | | NULL | |
| citycurstock | smallint(6) | YES | | NULL | |
| citylastprice | demical(4,2) | YES | | NULL | |
| city | varchar(60) | YES | | NULL | |
+--------------------+------------------+------+-----+---------+-------+
Anybody knows what is wrong with my query statement? or why doesn't this work?