Пример #1
0
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
0
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)