GremlinGraph#
- class langchain_community.graphs.gremlin_graph.GremlinGraph(url: str | None = None, username: str | None = None, password: str | None = None, traversal_source: str = 'g', message_serializer: Any | None = None)[source]#
Gremlin wrapper for graph operations.
Parameters: url (Optional[str]): The URL of the Gremlin database server or env GREMLIN_URI username (Optional[str]): The collection-identifier like ‘/dbs/database/colls/graph’
or env GREMLIN_USERNAME if none provided
- password (Optional[str]): The connection-key for database authentication
or env GREMLIN_PASSWORD if none provided
traversal_source (str): The traversal source to use for queries. Defaults to ‘g’. message_serializer (Optional[Any]): The message serializer to use for requests.
Defaults to serializer.GraphSONSerializersV2d0()
- Security note: Make sure that the database connection uses credentials
that are narrowly-scoped to only include necessary permissions. Failure to do so may result in data corruption or loss, since the calling code may attempt commands that would result in deletion, mutation of data if appropriately prompted or reading sensitive data if such data is present in the database. The best way to guard against such negative outcomes is to (as appropriate) limit the permissions granted to the credentials used with this tool.
See https://python.langchain.com/docs/security for more information.
- Implementation details:
The Gremlin queries are designed to work with Azure CosmosDB limitations
Create a new Gremlin graph wrapper instance.
Attributes
get_schema
Returns the schema of the Gremlin database
get_structured_schema
Return the schema of the Graph database
Methods
__init__
([url, username, password, ...])Create a new Gremlin graph wrapper instance.
add_edge
(relationship)add_graph_documents
(graph_documents[, ...])Take GraphDocument as input as uses it to construct a graph.
add_node
(node[, node_cache])build_edge_query
(relationship)build_vertex_query
(node)query
(query[, params])Query the graph.
Refreshes the Gremlin graph schema information.
- Parameters:
url (str | None)
username (str | None)
password (str | None)
traversal_source (str)
message_serializer (Any | None)
- __init__(url: str | None = None, username: str | None = None, password: str | None = None, traversal_source: str = 'g', message_serializer: Any | None = None) None [source]#
Create a new Gremlin graph wrapper instance.
- Parameters:
url (str | None)
username (str | None)
password (str | None)
traversal_source (str)
message_serializer (Any | None)
- Return type:
None
- add_edge(relationship: Relationship) Any [source]#
- Parameters:
relationship (Relationship)
- Return type:
Any
- add_graph_documents(graph_documents: List[GraphDocument], include_source: bool = False) None [source]#
Take GraphDocument as input as uses it to construct a graph.
- Parameters:
graph_documents (List[GraphDocument])
include_source (bool)
- Return type:
None
- build_edge_query(relationship: Relationship) str [source]#
- Parameters:
relationship (Relationship)
- Return type:
str
Examples using GremlinGraph