Replies: 3 comments 2 replies
-
Sorry about opening an issue. I did it from my mobile and didn't see the discussion tab |
Beta Was this translation helpful? Give feedback.
-
Hi, to be honest, I haven't spent much time looking into SQLAlchemy yet. The SQLAlchemy documentation in aiomysql as well as a good part of the general aiomysql documentation still needs a lot of work. To answer your questions: 1. Using transactionsTransactions are an optional feature, allowing you to e.g. group a series of statements to ensure they all are executed or none of them are. Note that you may want to either use 2. 2 Close functions
3. Engine initializationMy understanding of SQLAlchemy is that it maintains a connection pool, so it would be beneficial to keep the same engine across the lifetime of your application. 4. More detailed examplesSee also #475. 5. Migration guide & missing functionsContributions are welcome :) |
Beta Was this translation helpful? Give feedback.
-
@Nothing4You Regarding the close functions. Since we use a |
Beta Was this translation helpful? Give feedback.
-
In the example at https://github.com/aio-libs/aiomysql#example-of-sqlalchemy-optional-integration you acquire a connection but in the documentation at https://aiomysql.readthedocs.io/en/stable/sa.html you also create a transaction and commit.
In both examples you call 2 close functions. What is the reason for this?
What is a good practice to init the engine? Shall I init the engine every time I want to run a query and then call the 2 close functions?
Or shall I init the engine just once and close the engine when my app terminates ?
Add more detailed examples
The library is very similar to sqlalchemy, I like it. It was not hard to migrate to an async driver.
Maybe add a migration guide from sqlalchemy to aiomysql.
Also, some sqlalchemy functions are not available, like one_or_none. But I read that fetchone returns None so I will use that
Beta Was this translation helpful? Give feedback.
All reactions