How to write an MySQL update query using python 3.4 ? I'm using pymysql as a connector and I want to update a table in a database which is hosted on a localhost.
I have written one small piece of code but it is showing an error. probably because it is not compatible with python 3.4.
sql1 = ("""
UPDATE field_data_comment_body SET Sentiments=%s
WHERE comment_body_value=%s """, (para3,res))
cursor.execute(sql1)
while executing this it is showing an error
Traceback (most recent call last):
File "F:\The Script\new.py", line 44, in <module>
cursor.execute(sql1)
File "C:\Python34\lib\site-packages\pymysql-0.6.6-py3.4.egg\pymysql\cursors.py", line 134, in execute
result = self._query(query)
File "C:\Python34\lib\site-packages\pymysql-0.6.6-py3.4.egg\pymysql\cursors.py", line 282, in _query
conn.query(q)
File "C:\Python34\lib\site-packages\pymysql-0.6.6-py3.4.egg\pymysql\connections.py", line 767, in query
self._execute_command(COMMAND.COM_QUERY, sql)
File "C:\Python34\lib\site-packages\pymysql-0.6.6-py3.4.egg\pymysql\connections.py", line 957, in _execute_command
self._write_bytes(prelude + sql[:chunk_size-1])
TypeError: can't concat bytes to tuple
TypeError: can't concat bytes to tuple
so please help me find out the error !!