The reason for this error is to connect to MySQL through pymysql, and there is no operation to close the connection, so there will be no problems in a short time, and the connection will be confused if the connection is maintained for a long time. Although looking at my code is correct, I still report
pymysql.err.InterfaceError: (0,”) error. So this connection is either connected and then closed when it is used up. Or just use the following code to check if the connection exists, and reconnect if disconnected.
db = pymysql.connect(host = ' 127.0.0.1 ' ,port=3306,user = ' user ' , passwd = ' pwd ' , db = ' db_name ' , charset = ' utf8 ' ) sql ='select * from table_name' db.ping(reconnect = True) cur.execute(sql) db.commit()
end!
Similar Posts:
- [Solved] Python pymysql.err.OperationalError: (2013, ‘Lost connection to MySQL server during query…
- MySQL database insert into statement with parameters Error
- MySQL timestamp set default value error Invalid default value reason and solution
- [Solved] Last_IO_Error: error connecting to master ‘[email protected]:3306’ – retry-time: 60 …
- [Install OpenStack] Sync keystone database error: keystone DBConnectionError: (pymysql.err.OperationalError) (2003, “Can’t connect to MySQL server on ‘controller’ ([Errno 111] Connection refused)”)
- How to Solve Android wireless debug Error
- ORA-00980 synonym translation is no longer valid
- [Solved] Error when connecting to MySQL when creating Django project
- (20002, b’DB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (127.0.0…
- Redis Connect Error: It was not possible to connect to the redis server(s); to create a disconnected multiple