赞
踩
import pymysql
conn=pymysql.connect(host="填写数据库ip",
user="填写数据库用户名",
passwd="填写数据库用户密码",
db="填写数据库名",
port=端口号(一般是3306),
charset="utf8",
autocommit=True #此参数代表自动提交,如不写则需单独执行commit()命令
)
cursor=conn.cursor(pymysql.cursors.DictCursor)
#show tables;查看当前所有表
#cursor.execute("show tables;")
#cursor.execute('insert into students (name,phone,age,sex) values ("wxy",18500979583,18,"女");')
cursor.execute("select * from students limit 5")
print(cursor.description)
</
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。