Skip to content
Advertisement

Flask SQLAlchemy reflection ignoring most of tables on Redshift

I’m creating the engine and the Metadata as follows

JavaScript

Yields AttributeError: packages, and dir(Base.classes) returns no attributes with that name, neither with the orders name. Taking the only=['orders', 'packages'] off makes it reflect only a few random tables.

Now, when using the inspector that comes with native SQLAlchemy the table actually works (link to documentation):

JavaScript

Is this a bug, or am I overlooking something here?

Thanks!


Installed package versions:

JavaScript

Advertisement

Answer

SQLAlchemy’s automap extension only reflects tables which have defined primary keys.

From the note in the docs:

[…] for a table to be mapped, it must specify a primary key.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement