feat: Add neo4j db name support
This commit is contained in:
parent
aeb79761d6
commit
8d94b1ad37
3 changed files with 7 additions and 2 deletions
|
|
@ -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