DatabaseConnector
node_properties
property
Returns a list of dictionaries containing the node labels and their properties.
relationship_properties
property
Returns a list of dictionaries containing the relationship types and their properties.
relationships
property
Returns a list of dictionaries containing the source node label, relationship type, and target node label.
close()
Closes the connection to the Neo4j database.
constraints_exist()
Check and if constraints exist in the database. Return True if constraints exist.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if constraints exist in the database, False otherwise. |
execute_read(query, parameters=None)
Executes a read (MATCH) query using the Neo4j driver.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query
|
str
|
The Cypher query to execute. |
required |
parameters
|
dict
|
A dictionary of parameters to pass to the query. |
None
|
Returns:
Type | Description |
---|---|
list[dict[str, Any]]
|
list[dict]: The result of the query as a list of dictionaries. |
execute_write(query, parameters=None)
Executes a write (CREATE, DELETE, etc.) query using the Neo4j driver.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query
|
str
|
The Cypher query to execute. |
required |
parameters
|
dict
|
A dictionary of parameters to pass to the query. |
None
|
generate_model_diagram(models_path='pyeed/model.py')
Generates a arrows json file representing the model diagram.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
models_path
|
str
|
The path to the models file. Defaults to "pyeed/model.py". |
'pyeed/model.py'
|
initialize_db_constraints(user, password, models_path='model.py')
Run the neomodel_install_labels script to set up indexes and constraints on labels of Object-Graph Mapping (OGM) models.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user
|
str
|
The username for the Neo4j database. |
required |
password
|
str
|
The password for the Neo4j database. |
required |
models_path
|
str
|
The path to the models file. Defaults to "model.py". |
'model.py'
|
remove_db_constraints(user, password)
Run the neomodel_remove_labels script to drop all indexes and constraints from labels in the Neo4j database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
user
|
str
|
The username for the Neo4j database. |
required |
password
|
str
|
The password for the Neo4j database |
required |
stats()
Returns the number of nodes and relationships in the database.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict[str, int]
|
The number of nodes and relationships in the database. |
wipe_database(date=None)
Deletes all nodes and relationships in the database. The date parameter can be used but is not necessary. When not provided, all data will be deleted. If provided, the data will only be deleted if the date matches the current date. The format of the date should be 'YYYY-MM-DD'.