Hi. I'm migrating a python2 code base that used oursql to pymysql. I've noticed that pymysql doesn't automatically commit writes and have updated our application code to called connection.commit() after a successful write.
One thing that I'm confused about and currently digging into is that read isolation appears to be different. I have an application method that causes an update to be written to a row and committed on success, simplified version is:
def cancel_event(event_id):
event_object = event.get(event_id)
try:
event.update(event_id, cancel_payload) # committed write occurs here, using cursor.transaction.commit
event_object = event.get(event_id)
return jsonify(event_object)
except NotFound as e:
return jsonify(success=False, message=str(e)), 400
Using oursql the refresh `event_object = event.get(event_id)` sees the updated row just by doing a `cursor.execute('select * events where id = event_id')`. However using pymysql, the committed row is only visible to this process if I do
cursor.connection.begin()
cursor.execute('select * events where id = event_id')
DB config hasn't changed. I'm surprised that the read requires a new transaction to be started in order to see the committed update, and I'm uncertain if this will have larger implications for the rest of the application.
L