Python个使用pymysql 1.0.2版本 无法使用execute函数
环境:Python 3.8 pymysql1.0.2版本
代码如下:
import pymysql con = pymysql.connect(host=host, port=port, user=user, password=password charset='utf8') sql= 'SELECT * FROM * LIMIT 5;' with con as cur: cur.execute(sql) res = cur.fetchall() cur.close() print(res)
确认数据库能正常连接,与sql查询语句正常,运行时错误如下:
AttributeError: 'Connection' object has no attribute 'execute'
欢迎来到testingpai.com!
注册 关于