开发者

Why pymysql cursor changes during iteration where MySQLdb cursor doesn't?

Switching from MySQLdb to pymysql because of MySQLdb having issues while installing while moving my app to other systems

I have to iterate over large tables, in MySQLdb I used to for row in cursor instead of for row in cursor.fetchall()

for row in cursor:
    #some work
    cursor.execute("UPDATE table")
    cursor.execute("SELECT * FROM table")

This 开发者_如何学编程used to work perfectly

After switching to pymysql I noticed the for row in cursor does not work and cursor changes if I execute another query

This issue has been mentioned in github issues and there is a PULL request too which is rejected

Using for row in cursor.fetchall() is not recommended because it loads all data at once, causing my app KILLED

some comments say use a new cursor for each query, it it good when I have thousands of queries?

Or there is any way that I can modify my pymysql cursors code according to this https://github.com/PyMySQL/PyMySQL/pull/166/commits/94082775506aedc787eed96444b7fe297f9ae1a7

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜