Skip to content

the right way to autoload/reflect #110

Open

Description

@temoto

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?

Activity

  1. nhumrich commented on Oct 6, 2020

    @nhumrich
    Contributor

    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.

  2. temoto commented on Oct 6, 2020

    @temoto
    Author

    You may know better, but sqlalchemy docs say it's core. https://docs.sqlalchemy.org/en/13/core/reflection.html

  3. temoto commented on Oct 6, 2020

    @temoto
    Author
  4. nhumrich commented on Oct 6, 2020

    @nhumrich
    Contributor

    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.

  5. temoto commented on Oct 6, 2020

    @temoto
    Author

    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?

  6. nhumrich commented on Oct 8, 2020

    @nhumrich
    Contributor

    I honestly haven't looked into it too much, but I think if the Engine is implemented, that might be enough.

  7. temoto commented on Oct 8, 2020

    @temoto
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions