Search code examples
pythonneo4jpy2neo

Py2neo create node from object


Can someone help me with how to create a node from an object? e.g. we have object schema something like

class Person:
    def __init__(self, name, surname):
        self.name = name
        self.surname = surname

and I want to create py2neo Node Node("Person", name="John", surname="Doe") , however, I want to generalize this so I can use it with multiple schemas to something like Node(type(obj), **obj) but actually working.


Solution

  • Try using the py2neo.ogm module, as this is exactly what it is intended for. There are details of this in the docs.