I am using Python to access neo4j and create nodes. Before I create the node I want to check if it exists. I run this query:
"query" : "match (PPnode:Node) return PPnode"
And using the method of requests library:
r.text
I get a string, with the response of my POST request. My question is if there is a more "elegant" way to check if there are existing nodes with a specific name using python and rest api.
This is my code:
import requests
import json
import csv
headers = {'content-type': 'application/json'}
url = "http://localhost:7474/db/data/cypher"
fparts = open('FOC.csv')
csv_pseudo = csv.reader(fparts)
for row in csv_pseudo:
# query to check if node exists
checkNode = {"query" : "match (PPnode:Node) return PPnode"}
mkr =requests.post(url, data=json.dumps(checkNode), headers=headers)
Thanks Dimitris