I hope you all are doing well. I'm using for the moment py2neo however I'm not dead set on it. I'm trying to "speed up" my process, I have realized that py2neo is fairly slow so I'm trying my luck with some code magic...
From these benchmarks it appears that unwind is the fastest way to do stuff with db so here's my try...:
example = {}
example["name"] = "someName"
example["type"] = "Pet"
example["atr"] = "lel"
petArray = 100 * [example]
print("made my array of dicts", petArray)
tx.run('unwind $mapEntry as mItem create (n:mItem["type"] {name:mItem["name"], art:mItem["atr"]})', mapEntry=petArray)
tx.commit()
Now I'm getting the >
py2neo.database.ClientError: SyntaxError: Invalid input '[': expected an identifier character, whitespace, NodeLabel, a property map, ')' or a relationship pattern (line 1, column 42 (offset: 41))
"unwind $mapEntry as mItem create (n:mItem["type"] {name:mItem["name"], art:mItem["atr"]})"
I've tweaked my code for the moment to reflect this, as I though I will have to split my maps per "type" and batch individual type 1 by 1... I'll read on the CALL apoc part next!
So far I tweaked the code to be this >
tx.run(''' unwind $mapEntry as mItem
CREATE (n:Pet)
SET n = mItem
RETURN n'''
, mapEntry=petArray)
tx.commit()