sqlalchemy create database if not exists 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: create database if not exists
CREATE DATABASE [IF NOT EXISTS] database_name;