noctis.repository.neo4j.neo4j_repository.Neo4jRepository

class noctis.repository.neo4j.neo4j_repository.Neo4jRepository(uri: str | None = 'bolt://localhost:7687', username: str | None = '<put the correct value here and keep it secret>', password: str | None = '<put the correct value here and keep it secret>', database: str | None = None, schema: GraphSchema | None = GraphSchema(base_nodes={'chemical_equation': 'ChemicalEquation', 'molecule': 'Molecule'}, base_relationships={'product': {'type': 'PRODUCT', 'start_node': 'chemical_equation', 'end_node': 'molecule'}, 'reactant': {'type': 'REACTANT', 'start_node': 'molecule', 'end_node': 'chemical_equation'}}, extra_nodes={}, extra_relationships={}))[source]

Repository class for interacting with a Neo4j database using defined query strategies.

Attributes:

schema (GraphSchema): The schema used for graph operations. _driver (Driver): Neo4j driver for database connections. _query_strategies (dict[str, tuple[Callable, Callable]]): Mapping of query types to strategies and transaction functions.

__init__(uri: str | None = 'bolt://localhost:7687', username: str | None = '<put the correct value here and keep it secret>', password: str | None = '<put the correct value here and keep it secret>', database: str | None = None, schema: GraphSchema | None = GraphSchema(base_nodes={'chemical_equation': 'ChemicalEquation', 'molecule': 'Molecule'}, base_relationships={'product': {'type': 'PRODUCT', 'start_node': 'chemical_equation', 'end_node': 'molecule'}, 'reactant': {'type': 'REACTANT', 'start_node': 'molecule', 'end_node': 'chemical_equation'}}, extra_nodes={}, extra_relationships={}))[source]

Initialize the Neo4jRepository with connection details and schema.

Args:

uri (Optional[str]): URI of the Neo4j database. Defaults to settings.NEO4J_DEV_URL. username (Optional[str]): Username for authentication. Defaults to settings.NEO4J_DEV_USER. password (Optional[str]): Password for authentication. Defaults to settings.NEO4J_DEV_PASSWORD. database (Optional[str]): Database name, if applicable. Defaults to None. schema (Optional[GraphSchema]): Schema for graph operations. Defaults to a new GraphSchema instance.

Methods

__init__([uri, username, password, ...])

Initialize the Neo4jRepository with connection details and schema.

close()

Close the connection to the Neo4j database.

create_constraints()

Create uniqueness constraints in the Neo4j database using predefined queries.

drop_constraints()

Drop uniqueness constraints in the Neo4j database using predefined queries.

execute_custom_query_from_yaml(yaml_file, ...)

Execute a custom query defined in a YAML file.

execute_query(query_name, **kwargs)

Execute a predefined query by name.

info()

Returns info about all available queries, their required and optional arguments, and the query templates

show_constraints()

Show the current uniqueness constraints in the Neo4j database.