psqlpy-python / psqlpy

Asynchronous Python PostgreSQL driver written in Rust
https://psqlpy-python.github.io/
MIT License
226 stars 3 forks source link

Change PSQLPool connection method to sync and add async context manager #13

Closed chandr-andr closed 8 months ago

chandr-andr commented 8 months ago

Need to make PSQLPool.connection() method sync and add async context manager to it.
Main idea: connection method will create new Connection(1) object with structure connection: None, db_pool: . And when user will call any method on connection(1), we need to acquire db pool for read, retrieve new connection(2), put it in our Connection(1) object and then use only connection(2) for querying.

Add async context manager like in Transaction.

Try to add close() method for connection(1) to use Drop trait.

insani7y commented 8 months ago

It is not possible to do thread safely/without exclusive lock