def execute(self, context): es = ElasticHook(conn_id=self.elastic_conn_id) pg = PostgresHook(postgres_conn_id=self.postgres_conn_id) with closing(pg.get_conn()) as conn: with closing(conn.cursor()) as cursor: cursor.itersize = 1000 cursor.execute(self.sql) for row in cursor: doc = json.dumps(row, indent=2) es.add_doc(index=self.index, doc_type='external', doc=doc)
def _print_es_info(): hook = ElasticHook() print(hook.info())