Chronic stale results using MySQLdb in Python

前端 未结 3 571

My Python program queries a set of tables in a MySQL DB, sleeps for 30 seconds, then queries them again, etc. The tables in question are continuously updated by a third-par

3条回答
  •  旧巷少年郎
    2020-12-24 07:28

    This website and this website contain information on the same problem. In order to keep your tables up to date, you must commit your transactions. Use db.commit() to do this.

    As mentioned by the post below me, you can remove the need for this by enabling auto-commit. this can be done by running db.autocommit(True)

    Also, auto-commit is enabled in the interactive shell, so this explains why you didn't have the problem there.

提交回复
热议问题