In [2]:
Copied!
from pyeed import Pyeed
uri = "bolt://127.0.0.1:7687"
user = "neo4j"
password = "12345678"
# Create a Pyeed object, automatically connecting to the database
eedb = Pyeed(uri, user, password)
# Disconnect from the database
eedb.db.close()
from pyeed import Pyeed
uri = "bolt://127.0.0.1:7687"
user = "neo4j"
password = "12345678"
# Create a Pyeed object, automatically connecting to the database
eedb = Pyeed(uri, user, password)
# Disconnect from the database
eedb.db.close()
📡 Connected to database. 🔌 Connection closed.
Set and remove database constraints¶
Graph databases are "schema optional". However, constraints can be set to enforce data integrity.
To set the constraints of the pyeed graph model use the initialize_db_constraints
method. By default constraints are set based on the pyeed graph model. If a custom neomodel
model is used, the path to the corresponding file, outlining the graph model must be provided.
Defining the constraints ensures that some properties are unique and that some properties are mandatory. Furthermore, vector indices are created for the properties that are used for searching.
The constraint only need to be set once.
In [ ]:
Copied!
# Initialize the database constraints
eedb.db.initialize_db_constraints()
# Remove all database constraints
eedb.db.remove_db_constraints()
# Initialize the database constraints
eedb.db.initialize_db_constraints()
# Remove all database constraints
eedb.db.remove_db_constraints()