@songying
2018-09-20T18:36:19.000000Z
字数 468
阅读 1158
python库
pip install PyMySQL
import pymysql
connection = pymysql.connect(host='localhost',
user='user_name',
password='passwd',
db='database_name',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor)
connection.close() # 关闭连接
connection.commit() # 将操作提交到数据库
connection.rollback() # 数据库回滚
cursor = connection.cursor() # 返回Cursor对象
sql = "sql语句"
cursor.execute(sql)