asyncpgsa
asyncpgsa copied to clipboard
the right way to autoload/reflect
Please teach how to do Table(autoload=True)
or metadata.reflect()
with asyncpgsa properly.
Tried passing reflect(bind=asyncpgsa_connection)
and it's AttributeError game: needs connect then dialect, I feel like it's going in wrong direction.
People use psycopg2 to create sqlalchemy engine and then async driver for normal work. That may work if reflection doesn't use driver specifics. I'll use that crutch if nothing else works.
Can you create sqlalchemy Engine with asyncpgsa?
Autoreflection/Engine are orm properties. As the readme states, this repo currently doesn't support orm properties, only query builder (SQLAlchemy Core). I am not opposed to having this library support it, it is just out of the scope for myself, as I do not use the ORM/Engine side of sqlalchemy. Would be interested in reviewing a PR that attempts to add this to the library however.
You may know better, but sqlalchemy docs say it's core. https://docs.sqlalchemy.org/en/13/core/reflection.html
Engine is also in core. https://docs.sqlalchemy.org/en/13/core/engines_connections.html
Ok, yes, you are right, this is part of the "core" functionality section. And the fact that it just loads a table does make it core. Either way, today, the "engine" abstraction has yet to be implemented. Would be open to someone doing it.
I will do it but need a bit guidance. Do you know what exactly needs to be implemented: Engine or Connectable wrapper for SAConnection or CreateEnginePlugin or something else?
I honestly haven't looked into it too much, but I think if the Engine is implemented, that might be enough.
They have already implemented it https://github.com/sqlalchemy/sqlalchemy/blob/c3f102c9fe9811fd5286628cc6aafa5fbc324621/lib/sqlalchemy/ext/asyncio/engine.py
It seems sqlalchemy 1.4+ can be run without asyncpgsa altogether, but there is no shortage of issues reported and my task is overdue, so using psycopg2 for reflection so far. I'll post updates here.