Pymysql.err.InternalError: (1054, "Unknown column ' None ' in ' Field List ')

Source: Internet
Author: User
Tags postgresql






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 ')


Alibaba Cloud Hot Products

Elastic Compute Service (ECS) Dedicated Host (DDH) ApsaraDB RDS for MySQL (RDS) ApsaraDB for PolarDB(PolarDB) AnalyticDB for PostgreSQL (ADB for PG)
AnalyticDB for MySQL(ADB for MySQL) Data Transmission Service (DTS) Server Load Balancer (SLB) Global Accelerator (GA) Cloud Enterprise Network (CEN)
Object Storage Service (OSS) Content Delivery Network (CDN) Short Message Service (SMS) Container Service for Kubernetes (ACK) Data Lake Analytics (DLA)

ApsaraDB for Redis (Redis)

ApsaraDB for MongoDB (MongoDB) NAT Gateway VPN Gateway Cloud Firewall
Anti-DDoS Web Application Firewall (WAF) Log Service DataWorks MaxCompute
Elastic MapReduce (EMR) Elasticsearch

Alibaba Cloud Free Trail

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.