From 481bd25d29da90e7c4fcc05dd88b2cef9d34ba55 Mon Sep 17 00:00:00 2001 From: Tomaz Bratanic Date: Wed, 9 Oct 2024 05:17:55 +0530 Subject: [PATCH] community: Fix database connections for neo4j (#27190) Fixes https://github.com/langchain-ai/langchain/issues/27185 Co-authored-by: Erick Friis --- libs/community/langchain_community/graphs/neo4j_graph.py | 4 ++-- .../langchain_community/vectorstores/neo4j_vector.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/community/langchain_community/graphs/neo4j_graph.py b/libs/community/langchain_community/graphs/neo4j_graph.py index 901e9604f6..baca74bb3e 100644 --- a/libs/community/langchain_community/graphs/neo4j_graph.py +++ b/libs/community/langchain_community/graphs/neo4j_graph.py @@ -430,7 +430,7 @@ class Neo4jGraph(GraphStore): try: data, _, _ = self._driver.execute_query( Query(text=query, timeout=self.timeout), - database=self._database, + database_=self._database, parameters_=params, ) json_data = [r.data() for r in data] @@ -457,7 +457,7 @@ class Neo4jGraph(GraphStore): ): raise # fallback to allow implicit transactions - with self._driver.session() as session: + with self._driver.session(database=self._database) as session: data = session.run(Query(text=query, timeout=self.timeout), params) json_data = [r.data() for r in data] if self.sanitize: diff --git a/libs/community/langchain_community/vectorstores/neo4j_vector.py b/libs/community/langchain_community/vectorstores/neo4j_vector.py index 6f21eedd45..bb0be02afd 100644 --- a/libs/community/langchain_community/vectorstores/neo4j_vector.py +++ b/libs/community/langchain_community/vectorstores/neo4j_vector.py @@ -623,7 +623,7 @@ class Neo4jVector(VectorStore): params = params or {} try: data, _, _ = self._driver.execute_query( - query, database=self._database, parameters_=params + query, database_=self._database, parameters_=params ) return [r.data() for r in data] except Neo4jError as e: @@ -646,7 +646,7 @@ class Neo4jVector(VectorStore): ): raise # Fallback to allow implicit transactions - with self._driver.session() as session: + with self._driver.session(database=self._database) as session: data = session.run(Query(text=query), params) return [r.data() for r in data]