python3.x - When using pymysql to insert data in python, an error occurs when the data is an alphabetic string.
滿天的星座
滿天的星座 2017-06-12 09:25:33
0
1
1092

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?

滿天的星座
滿天的星座

reply all(1)
伊谢尔伦
insertSql = "INSERT INTO user(user_phone,user_name,user_password) VALUES(%s,'%s',%s)" % ('17855555555','lison','0000000')
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template