cancel
Showing results for 
Search instead for 
Did you mean: 

Pyneo Inserts Limited Amount of Edges

Molarix
Node

Hello, 

I am new to this forum, and hope this is the right place to post this.

For a university project I am using Neo4j together with flask and pyneo for a shift scheduling algorithm. On saving the scheduled shifts to Neo4j I realized that relationships go missing, from 330 only 91 get inserted. 

On printing them before/after inserting, they are in the list to be inserted, and I also moved the transaction around to check if this changes the result.

I have the following structure:
(w:Worker)-[r:works_during]->(s:Shift) with
r.day, r.month, r.year as set parameters for the relationship and multiple connections between each worker and each shift, which can be filtered via the relation then. 

my code looks like the following: 

 

 

        header = df.columns.tolist()
        header.remove("index")
        header.remove("worker")
        tuplelist = []
        for index, row in df.iterrows():
            for i in header:
                worker = self.driver.nodes.match("Worker", id=int(row["worker"])).first()
                if row[i] == 1:
                    # Shifts are in the format {day}_{shift_of_day}
                    shift_id = str(i).split("_")[1]
                    shift_day = str(i).split("_")[0]
                    shift = self.driver.nodes.match("Shift", id=int(shift_id)).first()
                    rel = Relationship(worker, "works_during", shift)
                    rel["day"] = int(shift_day)
                    rel["month"] = int(month)
                    rel["year"] = int(year)
                    tuplelist.append(rel)
        print(len(tuplelist))

        for i in tuplelist:
            connection = self.driver.begin()
            connection.create(i)
            connection.commit()

 

 

Is there any special behaviour in pyneo which I need to be aware of that could cause this issue?

Thanks for your help!

0 REPLIES 0
Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.