def is_db_user_superuser(conn):
    'Function to test whether the current DB user is a PostgreSQL superuser.'
    logger = logging.getLogger('dirbs.db')
    with conn.cursor() as cur:
        cur.execute('SELECT rolsuper\n                         FROM pg_roles\n                        WHERE rolname = CURRENT_USER')
        res = cur.fetchone()
        if (res is None):
            logger.warn('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.
def is_db_user_superuser(conn):
    
    logger = logging.getLogger('dirbs.db')
    with conn.cursor() as cur:
        cur.execute('SELECT rolsuper\n                         FROM pg_roles\n                        WHERE rolname = CURRENT_USER')
        res = cur.fetchone()
        if (res is None):
            logger.warn('Failed to find CURRENT_USER in pg_roles table')
            return False
        return res[0]