I am using SQLAlchemy to generate tables in a specific schema in a PostgreSQL database. If the schema does not exist, I want to create it. I know the PostgreSQL query to che
If you want to integrate it with SQLAlchemy you could use reflection but for an easier and quicker solution:
from sqlalchemy.sql import exists, select exists(select([("schema_name")]).select_from("information_schema.schemata"). where("schema_name == 'foo'"))
This will return True or False.
True
False