src/dirbs/utils.py
def is_db_user_superuser(conn):
    """
    Function to test whether the current DB user is a PostgreSQL superuser.

    Arguments:
        conn: dirbs db connection object
    Returns:
        bool to indicate result
    """
    logger = logging.getLogger('dirbs.db')
    with conn.cursor() as cur:
        cur.execute("""SELECT rolsuper
                         FROM pg_roles
                        WHERE rolname = CURRENT_USER""")
        res = cur.fetchone()
        if res is None:
            logger.warning('Failed to find CURRENT_USER in pg_roles table')
            return False
        return res[0]

    Function to test whether the current DB user is a PostgreSQL superuser.

    Arguments:
        conn: dirbs db connection object
    Returns:
        bool to indicate result
    
Function to test whether the current DB user is a PostgreSQL superuser.
Function to test whether the current DB user is a PostgreSQL superuser .
def is_db_user_superuser(conn):
    logger = logging.getLogger('dirbs.db')
    with conn.cursor() as cur:
        cur.execute("""SELECT rolsuper
                         FROM pg_roles
                        WHERE rolname = CURRENT_USER""")
        res = cur.fetchone()
        if res is None:
            logger.warning('Failed to find CURRENT_USER in pg_roles table')
            return False
        return res[0]
def is_db_user_superuser ( conn ) : logger = logging . getLogger ( 'dirbs.db' ) with conn . cursor ( ) as cur : cur . execute ( """SELECT rolsuper
                         FROM pg_roles
                        WHERE rolname = CURRENT_USER""" ) res = cur . fetchone ( ) if res is None : logger . warning ( 'Failed to find CURRENT_USER in pg_roles table' ) return False return res [ 0 ]
Function to test whether the current DB user is a PostgreSQL superuser.
Function to test whether the current DB user is a PostgreSQL superuser .
"""
    Function to test whether the current DB user is a PostgreSQL superuser.

    Arguments:
        conn: dirbs db connection object
    Returns:
        bool to indicate result
    """
bool to indicate result
bool to indicate result
conn
dirbs db connection object
dirbs db connection object