ElasticsearchSQLHook

Elasticsearch 钩子,通过 elasticsearch-dbapi 与 Elasticsearch 交互

使用示例

tests/system/providers/elasticsearch/example_elasticsearch_query.py[源代码]

    es = ElasticsearchSQLHook(elasticsearch_conn_id=CONN_ID)

    # Handle ES conn with context manager
    with es.get_conn() as es_conn:
        tables = es_conn.execute("SHOW TABLES")
        for table, *_ in tables:
            print(f"table: {table}")
    return True

此条目是否有用?