Ejemplo n.º 1
0
 def __init__(self, path):
     jpype.attachThreadToJVM()
     jpype.java.lang.System.setProperty("neo4j.ext.udc.source", "altneo4j")
     self._db = EmbeddedGraphDatabase(path)
     operations = GlobalGraphOperations.at(self._db)
     self.nodes = Nodes(self._db, operations)
     self.relationships = Relationships(self._db, operations)
Ejemplo n.º 2
0
class GraphDB(object):
    def __init__(self, path):
        jpype.attachThreadToJVM()
        jpype.java.lang.System.setProperty("neo4j.ext.udc.source", "altneo4j")
        self._db = EmbeddedGraphDatabase(path)
        operations = GlobalGraphOperations.at(self._db)
        self.nodes = Nodes(self._db, operations)
        self.relationships = Relationships(self._db, operations)

    def transaction(self):
        """Allows usage of the with-statement for Neo4j transactions::

          with graphdb.transaction:
              doMutatingOperations()
        """
        tx = self._db.beginTx()
        try:
            yield tx
            tx.success()
        finally:
            tx.finish()

    transaction = contextmanager(transaction)

    def node(self, **properties):
        node = self._db.createNode()
        for key, val in properties.items():
            node[key] = val
        return Node(node)

    def close(self):
        self._db.shutdown()
Ejemplo n.º 3
0
class GraphDB(object):

    def __init__(self, path):
        jpype.attachThreadToJVM()
        jpype.java.lang.System.setProperty("neo4j.ext.udc.source", "altneo4j")
        self._db = EmbeddedGraphDatabase(path)
        operations = GlobalGraphOperations.at(self._db)
        self.nodes = Nodes(self._db, operations)
        self.relationships = Relationships(self._db, operations)

    def transaction(self):
        """Allows usage of the with-statement for Neo4j transactions::

          with graphdb.transaction:
              doMutatingOperations()
        """
        tx = self._db.beginTx()
        try:
            yield tx
            tx.success()
        finally:
            tx.finish()
    transaction = contextmanager(transaction)

    def node(self, **properties):
        node = self._db.createNode()
        for key, val in properties.items():
            node[key] = val
        return Node(node)

    def close(self):
        self._db.shutdown()
Ejemplo n.º 4
0
 def __init__(self, path):
     jpype.attachThreadToJVM()
     jpype.java.lang.System.setProperty("neo4j.ext.udc.source", "altneo4j")
     self._db = EmbeddedGraphDatabase(path)
     operations = GlobalGraphOperations.at(self._db)
     self.nodes = Nodes(self._db, operations)
     self.relationships = Relationships(self._db, operations)