python - MySQL #1054 error code for UPDATE query -
i have mysql table looks like:
mysql> select * settings; +--------------+-------+ | name | value | +--------------+-------+ | connected | 0 | +--------------+-------+
and i'm trying update value timestamp connected through python code:
db1 = mysqldb.connect(host="localhost", user="user", passwd="password", db="database") cursor1 = db1.cursor() cursor1.execute("update settings set value = 'ts' name = connected") db1.commit() cursor1.close()
this returns me:
cursor1.execute("""update settings set value = 'ts' name = connected""")
file "/usr/lib/python2.7/dist-packages/mysqldb/cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
file "/usr/lib/python2.7/dist-packages/mysqldb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue _mysql_exceptions.operationalerror: (1054, "unknown column 'connected' in 'where clause'")
and can't figure out. appreciated.
1054, "unknown column 'connected' in 'where clause'
this error states connected
consider column name.
but here connected
string value want match columnname name
.
so need place single quote around connected
string solve issue:
cursor1.execute("update settings set value = 'ts' name = 'connected'")
Comments
Post a Comment