Error message:
Traceback (most recent call last):
File "D:/projectwc/test/dd.py", line 43, in <module> effect_row = cursor.execute("insert into `222` set c={}".format(None))
File "C:\python\lib\site-packages\pymysql\cursors.py", line 166, in execute
result = self._query(query)
File "C:\python\lib\site-packages\pymysql\cursors.py", line 322, in _query
conn.query(q)
File "C:\python\lib\site-packages\pymysql\connections.py", line 835, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "C:\python\lib\site-packages\pymysql\connections.py", line 1019, in _read_query_result
result.read()
File "C:\python\lib\site-packages\pymysql\connections.py", line 1302, in read
first_packet = self.connection._read_packet()
File "C:\python\lib\site-packages\pymysql\connections.py", line 981, in _read_packet
packet.check_error()
File "C:\python\lib\site-packages\pymysql\connections.py", line 393, in check_error
err.raise_mysql_exception(self._data)
File "C:\python\lib\site-packages\pymysql\err.py", line 107, in raise_mysql_exception raise errorclass(errno, errval)
pymysql.err.InternalError: (1054, "Unknown column ‘None‘ in ‘field list‘")
import pymysql
# Create connection
conn = pymysql.connect (host = ‘192.168.72.135’, port = 3306, user = ‘root’, passwd = ‘123456’, db = ‘test’)
# Create cursor
cursor = conn.cursor ()
# Execute SQL and return the number of affected rows
effect_row = cursor.execute ("insert into` 222` set c = {} ". format (None))
# Submit, otherwise the new or modified data cannot be saved
conn.commit ()
# Close cursor
cursor.close ()
# Close the connection
conn.close ()
Workaround:
Replace none with "Null"
Effect_row = Cursor.execute ("insert INTO ' 222 ' set c={}". Format ("Null "))
Pymysql.err.InternalError: (1054, "Unknown column ' None ' in ' Field List ')