Python MySQL连接器无法从SELECT查询返回所有结果

Python MySQL连接器无法从SELECT查询返回所有结果,python,mysql,sql,connector,mysql-connector-python,Python,Mysql,Sql,Connector,Mysql Connector Python,我使用mysql连接器python执行这个查询。代码是: try: conn = mycon.connect(user=****,password=****,host=****,database=****,autocommit=True) except mycon.Error as err: if err.errno == errorcode.ER_ACCESS_DENIED_ERROR: print("Authentication error - incorre

我使用mysql连接器python执行这个查询。代码是:

try:
    conn = mycon.connect(user=****,password=****,host=****,database=****,autocommit=True)
except mycon.Error as err:
    if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
        print("Authentication error - incorrect username and/or password.")
    elif err.errno == errorcode.ER_BAD_DB_ERROR:
        print("Database does not exist.")
    else:
        print(err)
cursor = conn.cursor()
no_of_results = cursor.execute("SELECT * FROM name_table\nLIMIT 0, 1000\n")
row = cursor.fetchone()
print(row)
while row is not None:
    row = cursor.fetchone()
    print(row)
cursor.close()
conn.close()
这将返回:

(1, 'Mains', 'Mains electrical circuit.')
(2, 'Solar', 'Solar panels.')
(3, 'AirCon', 'Air conditioner.')
(4, 'Oven', 'Oven.')
(5, 'Power1', 'General power circuit 1.')
(6, 'Power2', 'General power circuit 2.')
(7, 'Lights1', 'Lights circuit 1.')
(8, 'Lights2', 'Lights circuit 2.')
None
但是,如果我通过MySQL workbench运行完全相同的查询,返回的结果是:

我不知道为什么这两个查询返回不同的结果。我也在下面使用wireshark查看了网络流量信息,但我不清楚为什么会这样


在获取下一行之前,必须先打印该行,如下所示:

while row is not None:
    print(row)
    row = cursor.fetchone()

不,不是这样-请注意,“无”是最后打印的。其次,如果你查看wireshark日志,你会发现从服务器返回的数据不包括最后的结果。你有没有发现这个问题的根本原因?我有相反的问题。。。Python中的相同查询比Workbench多返回一个结果!