def refresh(self):
    'Refresh materialized views.\n\n        First, this method finds the namespaces being replicated, by referring to the\n        config for schemas and tables.\n\n        Then it finds any materialized views in the namespaces.\n\n        Then it refreshes the materialized views.\n        '
    print('Finding materialized views.')
    views = self._find_objects('m', self.repl_objects)
    if views:
        conn = psycopg2.connect(self.secondary_schema_owner_conn_pg_format)
        for view in views:
            print(f'Refreshing {view[0]}.{view[1]}')
            query = sql.SQL('REFRESH MATERIALIZED VIEW {schema}.{table}').format(schema=sql.Identifier(view[0]), table=sql.Identifier(view[1]))
            try:
                with conn.cursor() as cur:
                    cur.execute(query)
                    conn.commit()
            except Exception:
                conn.close()
                raise
        conn.close()
        print('Done refreshing views.')
    else:
        print('No materialized views found.')
Refresh materialized views.

First, this method finds the namespaces being replicated, by referring to the
config for schemas and tables.

Then it finds any materialized views in the namespaces.

Then it refreshes the materialized views.
def refresh(self):
    'Refresh materialized views.\n\n        First, this method finds the namespaces being replicated, by referring to the\n        config for schemas and tables.\n\n        Then it finds any materialized views in the namespaces.\n\n        Then it refreshes the materialized views.\n        '
    print('Finding materialized views.')
    views = self._find_objects('m', self.repl_objects)
    if views:
        conn = psycopg2.connect(self.secondary_schema_owner_conn_pg_format)
        for view in views:
            print(f'Refreshing {view[0]}.{view[1]}')
            query = sql.SQL('REFRESH MATERIALIZED VIEW {schema}.{table}').format(schema=sql.Identifier(view[0]), table=sql.Identifier(view[1]))
            try:
                with conn.cursor() as cur:
                    cur.execute(query)
                    conn.commit()
            except Exception:
                conn.close()
                raise
        conn.close()
        print('Done refreshing views.')
    else:
        print('No materialized views found.')