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
As of asyncpg v0.30.0 it is now possible to pass a custom connection function into the asyncpg.create_pool method, which means it is now possible to use the cloudsql connector without SQLAlchemy, thus maintaining the original API of the asyncpg pool (which is rather important if you are migrating an existing codebase that made heavy use of an asyncpg pool).
Might be helpful to future readers of the docs to reflect that here.
@jackwotherspoon - yes exactly. the getconn will need to have a call signature of async def getconn(dsn, **kwargs) I think, but it's up to the user to decide if they actually use those args or have some other mechanism for passing in the config to the connection.
yes exactly. the getconn will need to have a call signature of async def getconn(dsn, **kwargs) I think, but it's up to the user to decide if they actually use those args or have some other mechanism for passing in the config to the connection.
@d1manson do you have a working sample handy? I did a quick test and am running into some issues...
Activity
jackwotherspoon commentedon Oct 22, 2024
Hi @d1manson, thanks for pointing this out! (and being the one to commit this awesome feature) 😄
Do you have a working code sample handy? If so I'll test it out and get it added to our docs ASAP ✅
I assume it probably works similar to SQLAlchemy and I can just pass the
getconnas theconnectarg toasync.create_pool?Thanks again for this awesome feature and putting it on our radar 👍
d1manson commentedon Oct 22, 2024
@jackwotherspoon - yes exactly. the
getconnwill need to have a call signature ofasync def getconn(dsn, **kwargs)I think, but it's up to the user to decide if they actually use those args or have some other mechanism for passing in the config to the connection.jackwotherspoon commentedon Oct 24, 2024
@d1manson do you have a working sample handy? I did a quick test and am running into some issues...
jackwotherspoon commentedon Oct 24, 2024
Got a working example actually 👏
Will get a PR up shortly with a clean example.