I want to do the "CREATE SCHEMA IF NOT EXISTS" query in SQLAlchemy. Is there a better way than this:
engine = sqlalchemy.create_engine(connstr)
schema_name = config.get_config_value('db', 'schema_name')
#Create schema; if it already exists, skip this
try:
engine.execute(CreateSchema(schema_name))
except sqlalchemy.exc.ProgrammingError:
pass
I am using Python 3.5.