Module: Database Manager
DBManagement
Create DBManagement module
Examples:
clear_db(replace=True)
Replace or clear the entire database by a new one.
Note
Note about difference between replacing and clearing.
-
Replace: results in an Empty database that is completely replaced with a new database.
- Replacing a database is faster than clearing a database.
- Only possible when
- you have an Neo4j enterprise license
- you are running a local instance on the free Neo4j desktop version
-
Clear: Results in an empty database, however constraints are still in place.
- Clearing a database takes longer
- Independent of license
Parameters:
Name | Type | Description | Default |
---|---|---|---|
replace |
bool
|
boolean to indicate whether the database may be replaced |
True
|
Examples:
set_constraints()
get_all_rel_types()
Get all relationship types that are present in Neo4j instance
Returns:
Type | Description |
---|---|
List[str]
|
A list of strings with all relationship types present in the Neo4j instance |
get_all_node_labels()
Get all node labels that are present in Neo4j instance
Returns:
Type | Description |
---|---|
Set[str]
|
A list of strings with all node labels present in the Neo4j instance |
get_statistics()
Get the count of nodes per label and the count of relationships per type
Returns:
Type | Description |
---|---|
List[Dict[str, any]]
|
A list containing dictionaries with the label/relationship and its count |
print_statistics()
Print the statistics nicely using tabulate