【发布时间】:2020-04-19 19:58:29
【问题描述】:
我在从 Python 代码中获取查询结果时遇到问题。与数据库的连接似乎有效,但我总是收到错误:
"InterfaceError: No result set to fetch from."
有人可以帮我解决我的问题吗?谢谢!!!
cnx = mysql.connector.connect(
host="127.0.0.1" ,
user="root" ,
passwd="*****",
db="testdb"
)
cursor = cnx.cursor()
query = ("Select * from employee ;")
cursor.execute(query)
row = cursor.fetchall()
【问题讨论】:
-
试试
query = "Select * from employee"并添加print(cursor.fetchall())
标签: python mysql mysql-python fetchall