Skip to content

Neo4j backend

pylpg.backend.neo4j

Neo4j backend using the official Neo4j Python driver.

Classes:

Name Description
Neo4jBackend

Backend for Neo4j databases.

Neo4jBackend

Neo4jBackend(hostname: str = 'localhost', port: int = 7687, database: str = 'neo4j', username: str = 'neo4j', password: str = 'neo4j', protocol: str = 'bolt', notifications_min_severity: Literal['off', 'information', 'warning'] | None = None)

Bases: Backend

Backend for Neo4j databases.

Uses UNWIND queries for batch operations, providing significant speedups over individual queries at scale.

Source code in src/pylpg/backend/neo4j.py
def __init__(
    self,
    hostname: str = "localhost",
    port: int = 7687,
    database: str = "neo4j",
    username: str = "neo4j",
    password: str = "neo4j",
    protocol: str = "bolt",
    notifications_min_severity: typing.Literal["off", "information", "warning"]
    | None = None,
) -> None:
    uri = f"{protocol}://{hostname}:{port}"
    driver_kwargs: dict[str, typing.Any] = {"auth": (username, password)}
    if notifications_min_severity is not None:
        driver_kwargs["notifications_min_severity"] = (
            notifications_min_severity.upper()
        )
    self._driver = neo4j.GraphDatabase.driver(uri, **driver_kwargs)
    self._database = database