neo4jpy2neo

How to get a dictionary or list from <class 'py2neo.database.Record'>


Using py2neo to connect to neo4j DB: How can I convert "class 'py2neo.database.Record'" to a dictionary or list in python?


Solution

  • You can directly convert a Record to a list:

    result = graph.cypher.execute('MATCH (n) RETURN n')
    
    a_record = result[0] # -> this is a Record object
    
    list_of_things_in_record = list(a_record)
    
    print(list_of_things_in_record)