To retrieve a node's properties in Python with Neo4j, you can use the data()
method on the node object. Here's an example code snippet:
from neo4j import GraphDatabase
driver = GraphDatabase.driver("bolt://localhost:7687", auth=("neo4j", "password"))
session = driver.session()
result = session.run("MATCH (n:Person) WHERE n.name = 'John' RETURN n")
node = result.single()["n"]
properties = node.data()
print(properties)
In this example, we first create a connection to the Neo4j database using the GraphDatabase
class. Then we open a session using the driver.session()
method. We execute a Cypher query to retrieve a node with the name "John", and then we use the result.single()
method to retrieve the single record that was returned. We access the node object using the key "n", and then use the data()
method to retrieve the node's properties. Finally, we print the properties to the console.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-07-04 23:39:08 +0000
Seen: 12 times
Last updated: Jul 04 '23
How can a Neo4J database be queried recursively for a cypher?
Is there support for Gremlin in Neo4J?
Can the execution plan in neo4j be modified based on the limit of the return results?
How to connect Android Studio to Neo4j?
What does the error message "Invalid input: [, expected '+' or '-'" mean in neo4j?
How can large graphml files be filtered by removing certain portions?
What could be the reason for the invalid connection to neo4j in Android Studio?