这个问题在这里已经有答案了:
pymysql插入不工作(3个答案)
两年前关门了。
我哪里做错了?查询成功运行,但数据库表中没有数据存储
我的代码块是
import pymysql
db = pymysql.connect(host='', user='', passwd='',db='')
cursor = db.cursor()
cursor.executemany("""INSERT INTO Mention ( keyword, required, optional, excluded)
VALUES (%s,%s,%s,%s)""",
[
("Spam","fg","gtg","uu") ,
("dd","fg","gtg","uu") ,
("dd","fg","gtg","uu")
])
print(cursor.fetchmany())
1条答案
按热度按时间sdnqo3pr1#
建议将参数传递到execute函数中,因为它们将自动转义。
试试这个: