Skip to content

Commit

Permalink
fixing constraints problem when loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Yusuf Baktir committed Aug 26, 2020
1 parent 7bd2502 commit 504ce64
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
20 changes: 14 additions & 6 deletions nxneo4j/base_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 376,7 @@ def load_got(self):
MERGE (tgt:Character {name: row.Target})
// relationship for the book
MERGE (src)-[r:INTERACTS1]->(tgt)
ON CREATE SET r.weight = toInt(row.weight), r.book=1
ON CREATE SET r.weight = toInteger(row.weight), r.book=1
""")

session.run("""\
Expand All @@ -385,7 385,7 @@ def load_got(self):
MERGE (tgt:Character {name: row.Target})
// relationship for the book
MERGE (src)-[r:INTERACTS2]->(tgt)
ON CREATE SET r.weight = toInt(row.weight), r.book=2
ON CREATE SET r.weight = toInteger(row.weight), r.book=2
""")

session.run("""\
Expand All @@ -394,7 394,7 @@ def load_got(self):
MERGE (tgt:Character {name: row.Target})
// relationship for the book
MERGE (src)-[r:INTERACTS3]->(tgt)
ON CREATE SET r.weight = toInt(row.weight), r.book=3
ON CREATE SET r.weight = toInteger(row.weight), r.book=3
""")

session.run("""\
Expand All @@ -403,9 403,12 @@ def load_got(self):
MERGE (tgt:Character {name: row.Target})
// relationship for the book
MERGE (src)-[r:INTERACTS45]->(tgt)
ON CREATE SET r.weight = toInt(row.weight), r.book=45
ON CREATE SET r.weight = toInteger(row.weight), r.book=45
""")
session.run("""\
DROP CONSTRAINT ON (c:Character)
ASSERT c.name IS UNIQUE
""")

def load_euroads(self):
with self.driver.session() as session:
session.run("""\
Expand All @@ -426,7 429,9 @@ def load_euroads(self):
MERGE (origin)-[eroad:EROAD {road_number: row.road_number}]->(destination)
SET eroad.distance = toInteger(row.distance), eroad.watercrossing = row.watercrossing
""")

session.run("""\
DROP CONSTRAINT ON (c:Character) ASSERT c.name IS UNIQUE
""")
def load_twitter(self):
with self.driver.session() as session:
session.run("""\
Expand All @@ -445,3 450,6 @@ def load_twitter(self):
MERGE(f2:User {id: follower})
MERGE (u)<-[:FOLLOWS]-(f2));
""")
session.run("""\
DROP CONSTRAINT ON(u:User) ASSERT u.id IS unique
""")
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 27,7 @@
if __name__ == "__main__":
setup(
name="networkx-neo4j",
version="0.0.2dev1",
version="0.0.3",
maintainer="Mark Needham",
maintainer_email="[email protected]",
author="Mark Needham",
Expand Down
15 changes: 15 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,3 1,18 @@
"""
known fails
G.add_node("Betul",age=4)
G.add_node("Betul",age=5) #this does not update the first one
G.nodes['Betul']['age'] = 5 #also does not work
list(G.edges(data=True)) it would be nice to display labels here
G.edges(['Betul','Nurgul']) #FAILS
"""


from neo4j import GraphDatabase
import nxneo4j as nx

Expand Down

0 comments on commit 504ce64

Please sign in to comment.