1

By default the SQLAlchemy use public schema for Base. below is some code

        self.Base = automap.automap_base()
        self.Base.prepare(self.engine, reflect=True)
        Session = sessionmaker(bind = self.engine)
        self.session = Session()
        insp = reflection.Inspector.from_engine(self.engine)
        print(insp.get_table_names())

but this code lists me the tables of only public schema like this

['drs', 'spatial_ref_sys', 'users']

I want to handle all the tables from different schema. and not just the one in public. Any good way to get this done without much hassle ?

UPDATE 1 : Here is similar example with similar problem but with declarative case

Using a different schema for the same declarative Base in sqlalchemy

Abhijit Gujar
  • 433
  • 6
  • 15

1 Answers1

1

I encountered the same issue. In my case, I simply didn't set the primary key for the second schema. Since auto_map cannot map the tables without a primary key, it didn't show me the table from the second schema.

helvete
  • 2,455
  • 13
  • 33
  • 37