Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-19-2021 03:00 PM
Hello everyone.
I'm trying to handle the Constraint Validation exceptions into my Python code.
However I'm facing ModuleNotFoundError: No module named 'py2neo.cypher.error' error even after install py2neo==4.1.3.
My code:
from py2neo import Graph
from py2neo.cypher.error.schema import ConstraintViolation
import traceback
...
...
try:
...
...
except ConstraintViolation as e:
print(traceback.format_exc())
...
...
Does anyone already faced this?
How can I solve that?
Many thanks.
04-09-2021 01:47 AM
This code snipped seems to be written for an older version of py2neo. I'm not an export for py2neo but I think the current approach to this goes something along those lines:
from py2neo import Neo4jError
try:
...
except Neo4jError as e:
if e.code == "Neo.ClientError.Schema.ConstraintViolation":
....
else:
raise
Haven't tested it. So maybe it needs some slight adjustment.
Those links might be helpful:
All the sessions of the conference are now available online