You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Context manager for ConnectionPool#connection method #34
We have an asynchronous connection() method because we need to make an asynchronous call to the database pool.
When we get a connection that can be used in a context manager, it must have some magical method and access to the ConnectionPool.
If we want to have 2 ways of connection declaration, we need to be available to start it explicitly, like Transaction has a begin method.
Example:
# First without context manager
...
conn=connection_pool.connection()
awaitconn.start()
# Second with a context manager
...
asyncwithconnection_pool.connection() asconn:
It seems a bit complicated to me with some start method for connection.
If you have another opinion please share it.
Activity
chandr-andr commentedon Apr 17, 2024
Hi!
Thank you for the issue.
This idea is great, but It has some cons.
We have an asynchronous
connection()method because we need to make an asynchronous call to the database pool.When we get a connection that can be used in a context manager, it must have some magical method and access to the ConnectionPool.
If we want to have 2 ways of
connectiondeclaration, we need to be available to start it explicitly, likeTransactionhas abeginmethod.Example:
It seems a bit complicated to me with some
startmethod for connection.If you have another opinion please share it.
chandr-andr commentedon May 4, 2024
I've started implementing this, but I'm faced with performance issues.
#36
So, it will take time to understand how to do it in another way.
chandr-andr commentedon Jul 3, 2024
It's implemented in release https://github.com/qaspen-python/psqlpy/releases/tag/0.7.0 with the
acquiremethod.