I am new to using neo4j through python. I wanted to use APOC to read in a json file using python and populate a graph database. The JSON file is already in a neo4j required structure to create nodes and relationships.
When running the query CALL apoc.load.json("file:///xyz.json")
in neo4j Browser it runs fine and populates the nodes and relationships. But when I do it in python using py2neo it prints out the json file and nothing is added to the database when I check it in browser.
Python Code:
`from py2neo import Graph
g = Graph("bolt://localhost:7687", auth=("neo4j", "password"))
query = """
CALL apoc.load.json("file:///xyz.json")
"""
g.run(query)
`
The Json file is kept in import folder of the db.
As mentioned in the Neo4j APOC documentation, apoc.load.json just reads the json file and returns a map object. You will have to add further steps for node and relationship creation.
It looks like the query you had run in the neo4j browser had more to it. Or you might have mistaken a different Result frame to be from the json load apoc.