@db_cli.command('create')
@click.option('--overwrite/--no-overwrite', default=False, is_flag=True, show_default=True, help='If true, overwrite the database if it exists.')
@pass_psql_admin_connection
@click.pass_context
@dev_only
def create_database(ctx: click.Context, conn: connection, overwrite: bool=False):
    'Create the database from nothing.'
    database = current_app.config['POSTGRES_DB']
    cursor = conn.cursor()
    cursor.execute('ROLLBACK')
    if overwrite:
        cursor.execute(f"SELECT bool_or(datname = '{database}') FROM pg_database;")
        exists = cursor.fetchall()[0][0]
        if exists:
            ctx.invoke(delete_database)
    try:
        cursor.execute(f'CREATE DATABASE {database};')
    except psycopg2.errors.lookup('42P04'):
        click.echo(f'Database {database!r} already exists.')
        cursor.execute('ROLLBACK')
    else:
        click.echo(f'Created database {database!r}.')
Create the database from nothing.
@db_cli.command('create')
@click.option('--overwrite/--no-overwrite', default=False, is_flag=True, show_default=True, help='If true, overwrite the database if it exists.')
@pass_psql_admin_connection
@click.pass_context
@dev_only
def create_database(ctx: click.Context, conn: connection, overwrite: bool=False):
    
    database = current_app.config['POSTGRES_DB']
    cursor = conn.cursor()
    cursor.execute('ROLLBACK')
    if overwrite:
        cursor.execute(f"SELECT bool_or(datname = '{database}') FROM pg_database;")
        exists = cursor.fetchall()[0][0]
        if exists:
            ctx.invoke(delete_database)
    try:
        cursor.execute(f'CREATE DATABASE {database};')
    except psycopg2.errors.lookup('42P04'):
        click.echo(f'Database {database!r} already exists.')
        cursor.execute('ROLLBACK')
    else:
        click.echo(f'Created database {database!r}.')