aio-libs / aiomysql

aiomysql is a library for accessing a MySQL database from the asyncio
https://aiomysql.rtfd.io
MIT License
1.74k stars 256 forks source link

Examples #772

Closed anselal closed 2 years ago

anselal commented 2 years ago

Is your feature request related to a problem?

  1. In your 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. Which os the correct one to use?

  2. In both examples you call 2 close functions. What is the reason for this?

  3. 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 ?

Describe the solution you'd like

Add more detailed examples

Describe alternatives you've considered

The library is very similar to sqlalchemy, I like it. I 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

Additional context

No response

Code of Conduct