Read_transaction giving no results; query works fine in browser

Neo4j Desktop version: 1.4.7
Database version: 4.3.1
Driver version: 4.3.4

Hi all,

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 ="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:

I get no output from this.

Thanks in advance for any help!


Try using
Read about result objects here:

1 Like

Hi Andre,

Thanks very much for the quick response!

I've also played around with 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 =
    for key, value in
        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 =
    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.


Hi again all,

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.

Thanks for the replies guys!

Your original code doesn't work because the result goes out of scope when the function (and with it the transaction) ends.

Happy to hear you've got it working.

1 Like