标签:com exe 返回 mysql数据库 hal close username insert commit
import pymysql
conn = pymysql.connect(host=‘118.24.3.40‘,user=‘jxz‘,password=‘123456‘,port=3306,db=‘jxz‘,charset=‘utf8‘,autocommit=True)
cur = conn.cursor(pymysql.cursors.DictCursor) #建立游标
# sql=‘select * from app_myuser;‘
# sql=‘insert into app_myuser (username,passwd,is_admin) values ("nhy123","456789",1);‘
# cur.execute(sql)#只是执行sql,并不会返回数据
# conn.commit()
# print(cur.fetchall()) #获取到所有返回的数据
print(cur.fetchone()) #只取一条数据
cur.close()
conn.close()
标签:com exe 返回 mysql数据库 hal close username insert commit
原文地址:https://www.cnblogs.com/wangtingting920416/p/10099914.html