def can_db_user_create_roles(conn):
    'Function to test whether the current DB user has the CREATEROLE privilege.'
    logger = logging.getLogger('dirbs.db')
    with conn.cursor() as cur:
        cur.execute('SELECT rolcreaterole\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 has the CREATEROLE privilege.
def can_db_user_create_roles(conn):
    
    logger = logging.getLogger('dirbs.db')
    with conn.cursor() as cur:
        cur.execute('SELECT rolcreaterole\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]