MySQL/Python — committed changes not appearing in loop

后端 未结 1 672
生来不讨喜
生来不讨喜 2021-01-26 01:05

Using MySQL Connector/Python I have a loop that keeps checking a value for a change every 2 seconds. Without all the meat, here is the loop (the print is there for testing purp

1条回答
  •  清酒与你
    2021-01-26 01:46

    The default isolation level of InnoDB is REPEATABLE READ. This means that subsequent consistent SELECT statements will read the same snapshot established by the first within a transaction. Though you're opening and closing cursors, you're probably doing that inside a transaction and so you're reading the established snapshot over and over again. Either ROLLBACK or COMMIT to end the current transaction so that you can read values committed after the snapshot was taken.

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