I'm trying to get...well, any results from my database so far and nothing is coming back. My write_transaction of a works but read_transaction with even a basic query gives nothing, but the same query works fine in the Neo4j browser.
def find_nodes(tx):
result = tx.run("MATCH (n) RETURN n LIMIT 25")
return result
with driver.session(database="cophrdf") as session:
nodes = session.read_transaction(find_nodes)
for row in nodes:
print(row)
I've also played around with result.data() and unfortunately I get an empty dictionary. Here is the test I did:
def test_query(tx):
data = {}
query = ("MATCH (p) RETURN p LIMIT 25")
result = tx.run(query)
for key, value in result.data():
data[key] = value
return data
with driver.session() as session:
query_result = session.read_transaction(test_query)
for key, value in query_result.items():
print(f"{key}: {value}")
result.keys() gives me 'p' and result.values() is empty.
def test_query(tx):
query = "MATCH (p) RETURN p LIMIT 25"
result = tx.run(query)
return [row["p"] for row in result]
with driver.session() as session:
query_result = session.read_transaction(test_query)
for node in query_result:
print(f"Node {list(node.labels)} {dict(node)}")
Works for me. 4.3.4 driver with a 4.3.2 neo4j server. Make sure there are actually nodes in your database.
I don't know what changed with the update but after updating my Desktop and Browser versions it suddenly works with both my data test and your code rouven.bauer. My original code still doesn't but I'm going to assume that's me still trying to figure out what's going on here.