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()
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()
相关课程