# pip install sqlalchemy-utils from sqlalchemy_utils.functions import database_exists if database_exists(app.config["SQLALCHEMY_DATABASE_URI"]): # do stuff