Tuesday, 20 August 2013

How to check if PostgreSQL schema exists using SQLAlchemy?

How to check if PostgreSQL schema exists using SQLAlchemy?

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 check for the existence of the schema:
SELECT exists(select schema_name FROM information_schema.schemata WHERE
schema_name = 'foo')
but I want to know how I should handle this using SQLAlchemy.

No comments:

Post a Comment