本文整理汇总了Python中py2neo.Node.add_labels方法的典型用法代码示例。如果您正苦于以下问题:Python Node.add_labels方法的具体用法?Python Node.add_labels怎么用?Python Node.add_labels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类py2neo.Node
的用法示例。
在下文中一共展示了Node.add_labels方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: saveComponent
# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import add_labels [as 别名]
def saveComponent(properties, label, price, voorraad,link, winkel):
graph = Graph("http://localhost:7484/db/data/")
modelID = properties['ModelID']
if bool(graph.cypher.execute_one('match (n) where n.ModelID = "{}" return n'.format(modelID))):
cn = graph.cypher.execute_one('match (n) where n.ModelID = "{}" return n'.format(modelID))
else:
cn = Node(label)
for i in properties:
cn.properties[i] = properties[i]
graph.create(cn)
cn.add_labels('Component')
cn.push()
rel = Relationship(cn, 'SOLD_AT', winkel, Price=price, inStock=voorraad, productUrl=link)
graph.create(rel)
saveMetaData(winkel.properties['Name'], properties['Name'], modelID, price, properties['Merk'],'www.Informatique.nl', label)
time.sleep(3)
示例2: saveComponent
# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import add_labels [as 别名]
def saveComponent(properties, label, price, voorraad, link):
modelID = properties['ModelID']
if bool(neo4j_db.cypher.execute_one('match (n) where n.ModelID = "{}" return n'.format(modelID))):
cn = neo4j_db.cypher.execute_one('match (n) where n.ModelID = "{}" return n'.format(modelID))
else:
cn = Node(label)
for i in properties:
cn.properties[i] = properties[i]
neo4j_db.create(cn)
cn.add_labels('Component')
cn.push()
rel = Relationship(cn, 'SOLD_AT', store, Price=price, InStock=voorraad, productUrl=link)
neo4j_db.create(rel)
number = float(price)
# MongoDB
now = datetime.now()
post = {'ModelID': properties['ModelID'],
'Name': properties['Name'],
'Price': number,
'Brand': properties['Merk'],
'Type': label,
'Timestamp': int(time.mktime(now.timetuple()))}
if label == 'CPU': mongodb.CPU.insert(post)
elif label == 'Motherboard': mongodb.Motherboard.insert(post)
elif label == 'CPUFan': mongodb.CPUFan.insert(post)
elif label == 'GraphicsCard': mongodb.GraphicsCard.insert(post)
elif label == 'RAM': mongodb.RAM.insert(post)
elif label == 'Case': mongodb.Case.insert(post)
elif label == 'PSU': mongodb.PSU.insert(post)
elif label == 'Barebones': mongodb.Barebones.insert(post)
elif label == 'Storage-HDD': mongodb.HDD.insert(post)
elif label == 'Storage-SSD': mongodb.SSD.insert(post)
else: mongodb.MISC.insert(post)