def query_db_ownership(conn):
    'Function to verify whether the current database ownership is correct.'
    logger = logging.getLogger('dirbs.db')
    with conn.cursor() as cur:
        cur.execute('SELECT rolname\n                         FROM pg_roles\n                         JOIN pg_database\n                              ON (pg_database.datdba = pg_roles.oid)\n                        WHERE datname = current_database()')
        res = cur.fetchone()
        if (res is None):
            logger.warn('Failed to determing DB owner for current_database')
            return None
        return res[0]
Function to verify whether the current database ownership is correct.
def query_db_ownership(conn):
    
    logger = logging.getLogger('dirbs.db')
    with conn.cursor() as cur:
        cur.execute('SELECT rolname\n                         FROM pg_roles\n                         JOIN pg_database\n                              ON (pg_database.datdba = pg_roles.oid)\n                        WHERE datname = current_database()')
        res = cur.fetchone()
        if (res is None):
            logger.warn('Failed to determing DB owner for current_database')
            return None
        return res[0]