Search code examples
python-2.7neo4jtweepypy2neonode-neo4j

Check if node exist in my database Neo4j


please i can't check and create a node plus a relationship to pre-existing node.

i need to check if node pre-existing in my Neo4j database and create a node plus relationship to this node.

Thank you


Solution

  • Check out the py2neo docs for the Cypher support and use just a merge query like this:

    MERGE (user:User {name:"John"}) // get-or-crate
    MERGE (friend:User {name:"Jane"}) // create friend
    MERGE (user)-[r:KNOWS]->(friend) // create relationship
    RETURN user,r,friend