Hello,

I'm following the documentation for reflecting database tables using 
`automap`: 
http://docs.sqlalchemy.org/en/latest/orm/extensions/automap.html#generating-mappings-from-an-existing-metadata.

When I don't specific a schema, and Postgres uses the default `public` 
schema, this works as expected, and I find the names of my tables:

    >>> m = MetaData()
    >>> b = automap_base(bind=engine, metadata=m)
    >>> b.prepare(engine, reflect=True)
    >>> b.classes.keys()
    ['ads', 'spatial_ref_sys', 'income']

But when I specific an explicit schema, I don't have access to the tables 
in `Base.classes` anymore.

    >>> m = MetaData(schema='geography')
    >>> b = automap_base(bind=engine, metadata=m)
    >>> b.prepare(engine, reflect=True)
    >>> b.classes.keys()
    []

The MetaData reflected correctly though:

    >>> b.metadata.tables
    immutabledict({geography.usa_cbsa_centroids': 
Table('usa_cbsa_centroids', 
MetaData(bind=Engine(postgresql://asteroids:***@localhost:5432/asteroids)), 
Column('GEOID', VARCHAR(length=5), table=<u
    sa_cbsa_centroids>, nullable=False), ...})

Note that the tables and columns are only known at runtime.

Any thoughts?

This is duplicated 
from 
http://stackoverflow.com/questions/29905160/automap-reflect-tables-within-a-postgres-schema-with-sqlalchemy,
 
feel free to answer there as well.

Thanks,
Sam

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to