oso icon indicating copy to clipboard operation
oso copied to clipboard

[POC] Added Support for AsyncSession in SQLAlchemy 1.4+

Open zikphil opened this issue 3 years ago • 5 comments

Im adding a PoC for AsyncSession support in the latest sqlalchemy-oso module.

2 functions are added: authorized_async_sessionmaker and async_scoped_session, both are expecting AsyncSessions as opposed to normal Session.

SQLAlchemy converts all code to Sync when time comes to process signals so there shouldn't be a need for any modifications there. I have tested with the following code from your tutorial and got the expected output:

https://gist.github.com/zikphil/9b0c7d70b789796bcbcc56528e41ea51

Feel free to adapt this code as you see fit.

zikphil avatar Nov 28 '21 20:11 zikphil

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

github-actions[bot] avatar Nov 28 '21 20:11 github-actions[bot]

I have read the CLA Document and I hereby sign the CLA

zikphil avatar Nov 28 '21 20:11 zikphil

Hi @zikphil thanks for the contribution! I'm sorry it's taken us a few days to get to it — we've been pretty heads-down on getting ready for tomorrow's release. I'll make sure this PR gets reviewed ASAP

gj avatar Dec 01 '21 01:12 gj

Please review the new implementation. I have split it out in separate files and added a condition for SQLAlchemy => 1.4

zikphil avatar Dec 07 '21 16:12 zikphil

Hi @zikphil - do you have a chance to move forward with this PR? We had used it with a handful of calls so far and it worked fine, would be great to have it operating on top of oso 0.26.0   😇

alexhafner avatar Jan 26 '22 23:01 alexhafner