Closed vcalvert closed 2 years ago
@vcalvert have you a good alternative?
@sycured, at this time, we don't have a tested alternative. At the moment, we've just pinned SQLAlchemy to <1.4.
We might use the built-in SQLAlchemy AsyncEngine
via trio-asyncio
, as that's relatively straightforward, but that's the only good option I'm aware of at the moment for use with trio
. The AsyncEngine
and other now-builtin parts provide a lot of the context managers, etc. so it may be a reasonable approach. Implementing a trio
-compatible AsyncEngine
would be more work, but wouldn't require the additional dependency (which we already need for some other things).
@vcalvert not really because I've an issue with metadata.reflect() which isn't working with new create_async_engine
Maybe I'll move to another orm or language because I can't manage the database by the orm.
It's why I looked at sqlalchemy-aio but ok, I'll downgrade sqlalchemy and try it. Thanks
Would you mind reflecting the <1.4 requirement in the install_requires
of setup.py
?
Are there any plans to upgrade this lib to work with the latest sqla version?
There are no plans to support SQLAlchemy 1.4, which adds proper async support.
Any ideas on how to use it with trio?
Per the various above comments, the restriction on SQLAlchemy version has been added as of release 0.17.0.
As I noted above, one way to use newer SQLAlchemy with trio is to use the SQLAlchemy-provided asyncio code with trio-asyncio.
It's not terribly difficult, but it does bring in more dependences...
The other option is to essentially use a worker thread, i.e.
result = await trio.to_thread.run_sync(db_operation_fn, params)
In one particular case I wrapped this sort of logic into a class with some error handling and other mechanisms to cache the result and prevent multiple invocations of the database query.
Closing due to the noted breakage not being possible anymore.
so whats the fix for this guys?
This is the sort of error we see when attempting to use
sqlalchemy_aio
withtrio
andsqlalchemy==1.4.2
: