手记

python操作mysql数据库

import pymysql

db = pymysql.connect("192.168.3.5","root","passwd","dbname")
cursor = db.cursor()
sql = "select version()"
try:
cursor.execute(sql)
db.commit()
except Exception as e:
db.rollback()

db.close()

0人推荐
随时随地看视频
慕课网APP