Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions code/python/example.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
# pip3 install neo4j-driver
# pip3 install neo4j
# python3 example.py

from neo4j import GraphDatabase, basic_auth

driver = GraphDatabase.driver(
"neo4j://<HOST>:<BOLTPORT>",
auth=basic_auth("<USERNAME>", "<PASSWORD>"))

cypher_query = '''
MATCH (l:Location {address:$address})<-[r:OCCURRED_AT]-(c:Crime)
RETURN c.date as crimeDate
'''

with driver.session(database="neo4j") as session:
results = session.read_transaction(
lambda tx: tx.run(cypher_query,
address="Piccadilly").data())
for record in results:
print(record['crimeDate'])

driver.close()
with GraphDatabase.driver(
"neo4j://<HOST>:<BOLTPORT>",
auth=("<USERNAME>", "<PASSWORD>")
) as driver:
result = driver.execute_query(
cypher_query,
address="Piccadilly",
database_="neo4j")
for record in result.records:
print(record['crimeDate'])