community[minor]: Add the option to omit schema refresh in Neo4jGraph (#19654)

pull/19569/head^2
Tomaz Bratanic 3 months ago committed by GitHub
parent 5fc6531c74
commit 87d2a6b777
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -149,6 +149,8 @@ class Neo4jGraph(GraphStore):
sanitize (bool): A flag to indicate whether to remove lists with
more than 128 elements from results. Useful for removing
embedding-like properties from database responses. Default is False.
refresh_schema (bool): A flag whether to refresh schema information
at initialization. Default is True.
*Security note*: Make sure that the database connection uses credentials
that are narrowly-scoped to only include necessary permissions.
@ -170,6 +172,7 @@ class Neo4jGraph(GraphStore):
database: Optional[str] = None,
timeout: Optional[float] = None,
sanitize: bool = False,
refresh_schema: bool = True,
) -> None:
"""Create a new Neo4j graph wrapper instance."""
try:
@ -211,16 +214,17 @@ class Neo4jGraph(GraphStore):
"Please ensure that the username and password are correct"
)
# Set schema
try:
self.refresh_schema()
except neo4j.exceptions.ClientError as e:
if e.code == "Neo.ClientError.Procedure.ProcedureNotFound":
raise ValueError(
"Could not use APOC procedures. "
"Please ensure the APOC plugin is installed in Neo4j and that "
"'apoc.meta.data()' is allowed in Neo4j configuration "
)
raise e
if refresh_schema:
try:
self.refresh_schema()
except neo4j.exceptions.ClientError as e:
if e.code == "Neo.ClientError.Procedure.ProcedureNotFound":
raise ValueError(
"Could not use APOC procedures. "
"Please ensure the APOC plugin is installed in Neo4j and that "
"'apoc.meta.data()' is allowed in Neo4j configuration "
)
raise e
@property
def get_schema(self) -> str:

Loading…
Cancel
Save