Use pymysql to insert data in python3, the code is as follows
import pymysql
HOST = "localhost"
USER_NAME = "root"
PASSWORD = "712123000"
DB_NAME = "jiwenjuan"
def connDB():
conn = pymysql.connect(host=HOST,user=USER_NAME,passwd=PASSWORD,db=DB_NAME);
return conn
conn = connDB()
cursor = conn.cursor()
insertSql = "INSERT INTO user(user_phone,user_name,user_password) VALUES(%s,%s,%s)" % ('17855555555','lison','0000000')
cursor.execute(insertSql)
conn.commit()
The result is the following error:
pymysql.err.InternalError: (1054, "Unknown column 'lison' in 'field list'")
If you change "lison" to "123", a numeric string can be inserted. Please tell me the reason. Also, when the numeric string is "0000", the result saved in the database will become 0. How to stop him from converting it into numbers?