python中pymysql使用
python中pymysql使用
https://blog.csdn.net/johline/article/details/69549131
import pymysql # 连接数据库 connect = pymysql.Connect(host='localhost', port=3306, user='root', password='root', db='trademark', charset='utf8') # 获取游标 cursor = connect.cursor() # 插入数据 sql = "insert into tm_trademark (name) values('%s')" data = ('name01',) cursor.execute(sql % data) connect.commit() cursor.close() connect.close()