check if database exists mysql code example
Example 1: sqlalchemy check if database exists
# pip install sqlalchemy-utils
from sqlalchemy_utils.functions import database_exists
if database_exists(app.config["SQLALCHEMY_DATABASE_URI"]):
# do stuff
Example 2: python mysql check if database exists
CREATE DATABASE IF NOT EXISTS DBName;