示例#1
0
 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)
示例#2
0
def _print_es_info():
    hook = ElasticHook()
    print(hook.info())