All tables from Postgres in None
schema
#1566
-
I am using Alembic to manage my Postgres schema, and recently switched to using PostGIS which contains additional schemas. When trying to configure Alembic to ignore tables from the other schema's, all of the tables have the Where do I need to look at my config to determine how to fix this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
the "None" schema in your table metadata means the "default" schema which is what you see on PostgreSQL if you run this command:
we recommend that search_path is set to just "public", or if it includes the "$user" token, that the username used to log into the database is not the same name as a schema. overall, the exact meaning of None can be seen this way, where default_schema_name is what is assumed to be the schema when a Table otherwise has None for schema: >>> from sqlalchemy import create_engine
>>> e = create_engine("postgresql://scott:tiger@localhost/test", echo='debug')
>>> c = e.connect()
2024-11-04 17:46:50,056 INFO sqlalchemy.engine.Engine select pg_catalog.version()
2024-11-04 17:46:50,056 INFO sqlalchemy.engine.Engine [raw sql] {}
2024-11-04 17:46:50,057 DEBUG sqlalchemy.engine.Engine Col ('version',)
2024-11-04 17:46:50,057 DEBUG sqlalchemy.engine.Engine Row ('PostgreSQL 16.3 on x86_64-redhat-linux-gnu, compiled by gcc (GCC) 14.1.1 20240522 (Red Hat 14.1.1-4), 64-bit',)
2024-11-04 17:46:50,057 INFO sqlalchemy.engine.Engine select current_schema()
2024-11-04 17:46:50,057 INFO sqlalchemy.engine.Engine [raw sql] {}
2024-11-04 17:46:50,057 DEBUG sqlalchemy.engine.Engine Col ('current_schema',)
2024-11-04 17:46:50,057 DEBUG sqlalchemy.engine.Engine Row ('public',)
2024-11-04 17:46:50,058 INFO sqlalchemy.engine.Engine show standard_conforming_strings
2024-11-04 17:46:50,058 INFO sqlalchemy.engine.Engine [raw sql] {}
2024-11-04 17:46:50,058 DEBUG sqlalchemy.engine.Engine Col ('standard_conforming_strings',)
2024-11-04 17:46:50,058 DEBUG sqlalchemy.engine.Engine Row ('on',)
>>> c.dialect.default_schema_name
'public' |
Beta Was this translation helpful? Give feedback.
the "None" schema in your table metadata means the "default" schema which is what you see on PostgreSQL if you run this command:
we recommend that search_path is set to just "public", or if it includes the "$user" token, that the username used to log into the database is not the same name as a schema.
overall, the exact meaning of None can be seen this way, where default_schema_name is what is assumed to be the schema when a Table otherwise has None for schema: