Neo4j database wrapper for various graph operations.
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://docs.langchain.com/oss/python/security-policy for more information.
Neo4jGraph(
self,
url: Optional[str] = None,
username: Optional[str] = None,
password: Optional[str] = None,
token: Optional[str] = None,
database: Optional[str] = None,
timeout: Optional[float] = None,
sanitize: bool = False,
refresh_schema: bool = True,
*,
driver_config: Optional[Dict] = None,
enhanced_schema: bool = False
)| Name | Type | Description |
|---|---|---|
url | Optional[str] | Default: NoneThe URL of the Neo4j database server. |
username | Optional[str] | Default: NoneThe username for database authentication. |
password | Optional[str] | Default: NoneThe password for database authentication. |
token | Optional[str] | Default: NoneThe authentication token for database authentication. |
database | Optional[str] | Default: NoneThe name of the database to connect to. Default is |
timeout | Optional[float] | Default: NoneThe timeout for transactions in seconds. Useful for terminating long-running queries. Note By default, there is no timeout set. |
sanitize | bool | Default: FalseA flag to indicate whether to remove lists with more than 128 elements from results. Useful for removing embedding-like properties from database responses. |
refresh_schema | bool | Default: TrueA flag whether to refresh schema information at initialization. |
driver_config | Optional[Dict] | Default: NoneConfiguration passed to Neo4j Driver. |
enhanced_schema | bool | Default: FalseA flag whether to scan the database for example values and use them in the graph schema. |
Query Neo4j database.
Refreshes the Neo4j graph schema information.
This method constructs nodes and relationships in the graph based on the
provided GraphDocument objects.
Explicitly close the Neo4j driver connection.
Delegates connection management to the Neo4j driver.