def cypher_exec(self, statement): '''Wrapper to cypher.execute.''' if not DRY_RUN: if OFFLINE_MODE: CYPHER_STREAM.write(statement) else: self.graphDb.cypher.execute(statement)
def createModelGraph(sqlDb, graphDb): tableNodes = dict() for t in sqlDb.tableList: r = t.asNodeInfo() if r: labels, properties = r tableNodes[t.labelName] = Node(*labels, **properties) if not DRY_RUN: if OFFLINE_MODE: for node in tableNodes.values(): CYPHER_STREAM.write(createNodeCypher(node)) else: graphDb.graphDb.create(*tableNodes.values()) relations = list() for t in sqlDb.tableList: r = t.asRelInfo() if r: src, relType, dest, properties = r relations.append( Relationship(tableNodes[src], relType, tableNodes[dest], **properties)) for fk in t.fKeys: r = fk.asRelInfo() if r: src, relType, dest, properties = r relations.append( Relationship(tableNodes[src], relType, tableNodes[dest], **properties)) if not DRY_RUN: if OFFLINE_MODE: for rel in relations: CYPHER_STREAM.write(createRelTablesCypher(rel)) else: graphDb.graphDb.create(*relations)
def createModelGraph(sqlDb, graphDb): tableNodes = dict() for t in sqlDb.tableList: r = t.asNodeInfo() if r: labels, properties = r tableNodes[t.labelName] = Node(*labels, **properties) if not DRY_RUN: if OFFLINE_MODE: for node in tableNodes.values(): CYPHER_STREAM.write(createNodeCypher(node)) else: graphDb.graphDb.create(*tableNodes.values()) relations = list() for t in sqlDb.tableList: r = t.asRelInfo() if r: src, relType, dest, properties = r relations.append(Relationship(tableNodes[src], relType, tableNodes[dest], **properties)) for fk in t.fKeys: r = fk.asRelInfo() if r: src, relType, dest, properties = r relations.append(Relationship(tableNodes[src], relType, tableNodes[dest], **properties)) if not DRY_RUN: if OFFLINE_MODE: for rel in relations: CYPHER_STREAM.write(createRelTablesCypher(rel)) else: graphDb.graphDb.create(*relations)
def __del__(self): CYPHER_STREAM.__del__()