python3之查询数据库
python3之链接数据库
首先 安装 pip install pymysql
代码:
import pymysql
db = pymysql.connect(host=“xxxxx”, user=‘xxxx’, password='xxxxx’, database=“xxxxx”, charset=‘utf8’)
sql = (“SELECT * FROM t_user”)
try:
cursor.execute(sql)
result = cursor.fetchall()
except:
print
原创
2020-06-11 21:28:50 ·
442 阅读 ·
0 评论