def setrole_connection(*, sender: Type[PostgreSQLDatabaseWrapper],
                       connection: PostgreSQLDatabaseWrapper,
                       **kwargs: Any) -> None:
    global warning_given
    role = None
    if "set_role" in connection.settings_dict:
        role = connection.settings_dict["set_role"]
    elif "SET_ROLE" in connection.settings_dict:
        role = connection.settings_dict["SET_ROLE"]

    if role:
        connection.cursor().execute("SET ROLE %s", (role, ))
    else:
        if not warning_given:
            warnings.warn(
                "postgresql_setrole app is installed, but no SET_ROLE value is in settings.DATABASE"
            )
            warning_given = True  # Once is enough
def database_init_signal(signal, sender: DatabaseWrapper,
                         connection: DatabaseWrapper, **kwargs):
    """ On database connection create Database """
    database_name: str = f"{settings.DATABASES['default']['NAME']}"

    cursor = connection.cursor()

    try:
        cursor.execute(f'CREATE DATABASE "{database_name}"')
    except ProgrammingError:
        print("Database already exist")