Add neo4j multi db support (#1207)
<!-- .github/pull_request_template.md --> ## Description Add multi db support for Neo4j Enterprise users ## DCO Affirmation I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin. --------- Signed-off-by: Raj2604 <rajmandhare26@gmail.com> Co-authored-by: vasilije <vas.markovic@gmail.com> Co-authored-by: Vasilije <8619304+Vasilije1990@users.noreply.github.com> Co-authored-by: Daulet Amirkhanov <damirkhanov01@gmail.com> Co-authored-by: Hande <159312713+hande-k@users.noreply.github.com> Co-authored-by: Boris <boris@topoteretes.com> Co-authored-by: Matea Pesic <80577904+matea16@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions@users.noreply.github.com> Co-authored-by: hajdul88 <52442977+hajdul88@users.noreply.github.com> Co-authored-by: Boris Arzentar <borisarzentar@gmail.com> Co-authored-by: Raj Mandhare <96978537+Raj2604@users.noreply.github.com> Co-authored-by: Pedro Thompson <thompsonp17@hotmail.com> Co-authored-by: Pedro Henrique Thompson Furtado <pedrothompson@petrobras.com.br>
This commit is contained in:
parent
dabd0912f8
commit
b54e843951
4 changed files with 8 additions and 2 deletions
|
|
@ -71,6 +71,7 @@ GRAPH_DATABASE_PROVIDER="kuzu"
|
|||
# -- To switch to Neo4j uncomment and fill these: -------------------------------------------------------------------
|
||||
#GRAPH_DATABASE_PROVIDER="neo4j"
|
||||
#GRAPH_DATABASE_URL=bolt://localhost:7687
|
||||
#GRAPH_DATABASE_NAME="neo4j"
|
||||
#GRAPH_DATABASE_USERNAME=neo4j
|
||||
#GRAPH_DATABASE_PASSWORD=localneo4j
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ class GraphConfig(BaseSettings):
|
|||
graph_database_provider: str = Field("kuzu", env="GRAPH_DATABASE_PROVIDER")
|
||||
|
||||
graph_database_url: str = ""
|
||||
graph_database_name: str = ""
|
||||
graph_database_username: str = ""
|
||||
graph_database_password: str = ""
|
||||
graph_database_port: int = 123
|
||||
|
|
@ -105,6 +106,7 @@ class GraphConfig(BaseSettings):
|
|||
return {
|
||||
"graph_database_provider": self.graph_database_provider,
|
||||
"graph_database_url": self.graph_database_url,
|
||||
"graph_database_name": self.graph_database_name,
|
||||
"graph_database_username": self.graph_database_username,
|
||||
"graph_database_password": self.graph_database_password,
|
||||
"graph_database_port": self.graph_database_port,
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ def create_graph_engine(
|
|||
graph_database_provider,
|
||||
graph_file_path,
|
||||
graph_database_url="",
|
||||
graph_database_name="",
|
||||
graph_database_username="",
|
||||
graph_database_password="",
|
||||
graph_database_port="",
|
||||
|
|
@ -86,6 +87,7 @@ def create_graph_engine(
|
|||
graph_database_url=graph_database_url,
|
||||
graph_database_username=graph_database_username or None,
|
||||
graph_database_password=graph_database_password or None,
|
||||
graph_database_name=graph_database_name or None,
|
||||
)
|
||||
|
||||
elif graph_database_provider == "falkordb":
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ class Neo4jAdapter(GraphDBInterface):
|
|||
graph_database_url: str,
|
||||
graph_database_username: Optional[str] = None,
|
||||
graph_database_password: Optional[str] = None,
|
||||
graph_database_name: Optional[str] = None,
|
||||
driver: Optional[Any] = None,
|
||||
):
|
||||
# Only use auth if both username and password are provided
|
||||
|
|
@ -59,7 +60,7 @@ class Neo4jAdapter(GraphDBInterface):
|
|||
elif graph_database_username or graph_database_password:
|
||||
logger = get_logger(__name__)
|
||||
logger.warning("Neo4j credentials incomplete – falling back to anonymous connection.")
|
||||
|
||||
self.graph_database_name = graph_database_name
|
||||
self.driver = driver or AsyncGraphDatabase.driver(
|
||||
graph_database_url,
|
||||
auth=auth,
|
||||
|
|
@ -80,7 +81,7 @@ class Neo4jAdapter(GraphDBInterface):
|
|||
"""
|
||||
Get a session for database operations.
|
||||
"""
|
||||
async with self.driver.session() as session:
|
||||
async with self.driver.session(database=self.graph_database_name) as session:
|
||||
yield session
|
||||
|
||||
@deadlock_retry()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue