查询执行没有返回值。
您需要遵循的模式是:
cursor creation;cursor, execute query;cursor, *fetch rows*;
或在python中:
c = d.cursor()c.execute(query) # selected rows stored in cursor memoryrows = c.fetchall() # get all selected rows, as Barmar mentionedfor r in rows: print(r)
还有一些数据库模块允许您使用for … in模式遍历游标,但对mysql进行三重检查。



