我使用 Python 连接到 MariaDB。我最近从这个页面从 PyMySQL 切换到本机连接器,但我无法使用这个简单的代码:
a = mysql.connect(host='127.0.0.1', port=3306, user='root', db='db', passwd='1337')
b = a.cursor()
b.execute('SELECT * FROM accounts', multi=True)
b.execute('SELECT * FROM profile', multi=True)
print(b.fetchall())
a.commit()
我以为它会打印表中的所有行profile
,但由于某种原因它不会,并退出并出现以下错误
Traceback (most recent call last):
File "<file>", line 142, in <module>
print(b.fetchall())
File "/usr/local/lib/python3.3/dist-packages/mysql/connector/cursor.py", line 676, in fetchall
raise errors.InterfaceError("No result set to fetch from.")
mysql.connector.errors.InterfaceError: No result set to fetch from.