Airflow Summit 2025 is coming October 07-09. Register now for early bird ticket!

airflow.providers.apache.tinkerpop.hooks.gremlin

This module allows connecting to an Graph DB using the Gremlin Client.

Attributes

logger

Classes

GremlinHook

Interact with Graph DB using the Gremlin Client.

Module Contents

airflow.providers.apache.tinkerpop.hooks.gremlin.logger[source]
class airflow.providers.apache.tinkerpop.hooks.gremlin.GremlinHook(conn_id=default_conn_name, *args, **kwargs)[source]

Bases: airflow.hooks.base.BaseHook

Interact with Graph DB using the Gremlin Client.

This hook creates a connection to Graph DB and allows you to run Gremlin queries.`

Parameters:

gremlin_conn_id – Reference to the connection ID configured in Airflow.

conn_name_attr = 'gremlin__conn_id'[source]
default_conn_name = 'gremlin_default'[source]
conn_type = 'gremlin'[source]
hook_name = 'Gremlin'[source]
default_port = 443[source]
traversal_source = 'g'[source]
gremlin_conn_id = 'gremlin_default'[source]
connection[source]
client: gremlin_python.driver.client.Client | None = None[source]
get_conn(serializer=None)[source]

Establish a connection to Graph DB with the Gremlin Client.

Parameters:

serializer – Message serializer to use for the client.

Returns:

An instance of the Gremlin Client.

Return type:

gremlin_python.driver.client.Client

get_uri(conn)[source]

Build the URI from the connection object and extra parameters.

Parameters:

conn (airflow.models.Connection) – Airflow Connection object.

Returns:

URI string.

Return type:

str

get_client(conn, traversal_source, uri, message_serializer=None)[source]

Create and return a new Gremlin client.

Parameters:
  • conn (airflow.models.Connection) – Airflow Connection object.

  • traversal_source (str) – Traversal source for the Gremlin client.

  • uri (str) – URI string for connecting to Graph DB.

  • message_serializer – Message serializer to use for the client.

Returns:

An instance of the Gremlin Client.

Return type:

gremlin_python.driver.client.Client

run(query, serializer=None, bindings=None, request_options=None)[source]

Execute a Gremlin query and return the results.

Parameters:
  • query (str) – Gremlin query string.

  • serializer – Message serializer to use for the query.

  • bindings – Bindings to use for the query.

  • request_options – Request options to use for the query.

Returns:

List containing the query results.

Return type:

list[Any]

Was this entry helpful?