win10,python2.7,mysql-connector-python 报错 mysql.connector.errors.InternalError: Unread result found

Traceback (most recent call last):
  File "C:/Users/rHotD/Documents/Work/apollo_test_case_2/testcase/test_mysql.py", line 26, in 
    cur.close()
  File "C:\Program Files\Python2.7\lib\site-packages\mysql\connector\cursor.py", line 388, in close
    self._connection.handle_unread_result()
  File "C:\Program Files\Python2.7\lib\site-packages\mysql\connector\connection.py", line 1063, in handle_unread_result
    raise errors.InternalError("Unread result found")
mysql.connector.errors.InternalError: Unread result found

win10,python2.7,mysql-connector-python 报错 mysql.connector.errors.InternalError: Unread result found_第1张图片

from mysql import connector

conn = connector.connect(
            host='xxx.xxx.xxx.xxx',
            port=3306,
            user='xxxxxxx',
            passwd='xxxxxxxxxx',
            db='xxxxxxxxxxxxxxxxx',
            charset='utf8'
            )

cur = conn.cursor()

message_sum = cur.execute("select * from xxxxxxxxxxx")

print(message_sum)

fiveD_upass_tuple = cur.fetchmany(message_sum)

# print(type(fiveD_upass_tuple))

# for fiveD_upass in fiveD_upass_tuple:
#     print(fiveD_upass)

cur.close()
conn.commit()
conn.close()

解决办法

cur = conn.cursor(buffered=True)

加上 buffered=True

即可

Python MySQL connector - unread result found when using fetchone

你可能感兴趣的:(MySQL)