ArangoGraph#

class langchain_community.graphs.arangodb_graph.ArangoGraph(db: Any)[source]#

ArangoDB wrapper for graph operations.

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.

Create a new ArangoDB graph wrapper instance.

Attributes

db

schema

Methods

__init__(db)

Create a new ArangoDB graph wrapper instance.

from_db_credentials([url,Β dbname,Β username,Β ...])

Convenience constructor that builds Arango DB from credentials.

generate_schema([sample_ratio])

Generates the schema of the ArangoDB Database and returns it User can specify a sample_ratio (0 to 1) to determine the ratio of documents/edges used (in relation to the Collection size) to render each Collection Schema.

query(query[,Β top_k])

Query the ArangoDB database.

set_db(db)

set_schema([schema])

Set the schema of the ArangoDB Database.

Parameters:

db (Any) –

__init__(db: Any) β†’ None[source]#

Create a new ArangoDB graph wrapper instance.

Parameters:

db (Any) –

Return type:

None

classmethod from_db_credentials(url: str | None = None, dbname: str | None = None, username: str | None = None, password: str | None = None) β†’ Any[source]#

Convenience constructor that builds Arango DB from credentials.

Parameters:
  • url (str | None) – Arango DB url. Can be passed in as named arg or set as environment var ARANGODB_URL. Defaults to β€œhttp://localhost:8529”.

  • dbname (str | None) – Arango DB name. Can be passed in as named arg or set as environment var ARANGODB_DBNAME. Defaults to β€œ_system”.

  • username (str | None) – Can be passed in as named arg or set as environment var ARANGODB_USERNAME. Defaults to β€œroot”.

  • password (str | None) – Can be passed ni as named arg or set as environment var ARANGODB_PASSWORD. Defaults to β€œβ€.

Returns:

An arango.database.StandardDatabase.

Return type:

Any

generate_schema(sample_ratio: float = 0) β†’ Dict[str, List[Dict[str, Any]]][source]#

Generates the schema of the ArangoDB Database and returns it User can specify a sample_ratio (0 to 1) to determine the ratio of documents/edges used (in relation to the Collection size) to render each Collection Schema.

Parameters:

sample_ratio (float) –

Return type:

Dict[str, List[Dict[str, Any]]]

query(query: str, top_k: int | None = None, **kwargs: Any) β†’ List[Dict[str, Any]][source]#

Query the ArangoDB database.

Parameters:
  • query (str) –

  • top_k (int | None) –

  • kwargs (Any) –

Return type:

List[Dict[str, Any]]

set_db(db: Any) β†’ None[source]#
Parameters:

db (Any) –

Return type:

None

set_schema(schema: Dict[str, Any] | None = None) β†’ None[source]#

Set the schema of the ArangoDB Database. Auto-generates Schema if schema is None.

Parameters:

schema (Dict[str, Any] | None) –

Return type:

None

Examples using ArangoGraph