Closed AivanF closed 5 years ago
You probably have to conn.commit()
even after a SELECT
query - otherwise a run of SELECT queries are done within the same transaction as the first.
(I think most users are accustomed to "autocommit" by default, but that does not seem to be the default mode for TorMySQL)
You probably have to
conn.commit()
even after aSELECT
query - otherwise a run of SELECT queries are done within the same transaction as the first.
Thank you very much, Pierce! Now the code works excellent. My perfectionism (desire to reduce commits) was wrong at this time 😅 If you want, you can also write an answer to the same question on StackOverflow, I'll plus it.
sure, thanks :)
oo, verygood
My task
I have an old, large project based in Python 2.7 with Tornado framework. To work with MySQL, it initially used Tornado-MySQL with raw SQL queries, and it worked well, but now I have to deal with MySQL 8, and that library is obsolete, unmaintained.
So, now I use TorMySQL library – it connects easily to MySQL Server 8 and mainly works well. However, I don't fully understand how to use it, and this leads some bugs: different clients of the web application see different versions of data, like if they had different connections with own uncommitted data. The data eventually becomes updated, but too late.
Current code
All the work with database is handled by file
database.py
which is used in lots of other files. Here is it's simplified code:The question
How to solve the problem?
I suppose it is related to the pool – maybe I have to close / recreate it? The example on main page of TorMySQL also has this line:
yield pool.close()
but I found no option to use it in my code.