PyMySQL returning old/snapshot values/not rerunning query?

前端 未结 1 351
误落风尘
误落风尘 2020-12-17 16:32

I\'m using pymysql.cursors and a simplified code example that loads a row from a table and prints it every second is:

#!/usr/bin/env python3
imp         


        
相关标签:
1条回答
  • 2020-12-17 17:00

    I do not understand why this is necessary, but you can fix it by either

    1. Adding autocommit=True into the connect() parameters.

    2. Calling conn.commit() after the cursor.execute() command.

    Seems it starts a transaction at a snapshot or something by default. I (nervously!) submitted an issue on the pymysql repo, as I'd not heard anything back here. This was closed immediately with the explanation

    It's repeatable read

    If anyone knows something better than using autocommit let me know.

    0 讨论(0)
提交回复
热议问题