I am trying to implement this very same scenario in Python: https://neo4j.com/docs/developer-manual/current/cypher/clauses/create/#create-create-multiple-nodes-with-a-parameter-for-their-properties
What I am trying to do is to insert in a graph all links found in a wikipedia page as nodes but I am stuck at the creation step.
import wikipedia
from py2neo import Graph
first_page = "United Kingdom"
page = wikipedia.page(first_page)
page_name = page.title
page_id = page.pageid
links = page.links
graph = Graph(bolt=True, password="mypassword")
nodes = {}
nodes['Page'] = list({"title" : c} for c in page.links)
node = "UNWIND {json} as data CREATE (n) SET n = data"
graph.run(node, json=nodes)
If I print the nodes dictionary, it is in the very same format shown in the link above from the Neo4j documentation, below for reference.
{
"props" : [ {
"name" : "Andres",
"position" : "Developer"
}, {
"name" : "Michael",
"position" : "Developer"
} ]
}
however in my case I receive the following error message:
py2neo.status.CypherTypeError: Property values can only be of primitive types or arrays thereof.
I am trying to find an way to create nodes with a single statement, is this even possible using Python?