当前位置: 首页>>代码示例>>Python>>正文


Python Node.push方法代码示例

本文整理汇总了Python中py2neo.Node.push方法的典型用法代码示例。如果您正苦于以下问题:Python Node.push方法的具体用法?Python Node.push怎么用?Python Node.push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在py2neo.Node的用法示例。


在下文中一共展示了Node.push方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: addMultiNodesFromJsonFile

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import push [as 别名]
def addMultiNodesFromJsonFile(neoGraph,filename):
    file = open(filename)
# for all lines in the file
    while 1:
        line = file.readline()
        if not line:
            break
        # replace '' with ""
        respCmtJson = line.replace("'", "\"");
        # ture string to json
        js = simplejson.loads(respCmtJson)
        # lable  and key_values
        labels = []
        key_values = {}
        #put ID into the dict
        key_values['ID'] = js['ID']
        keyValues = js['AVP_LIST']
        # for all key_values in the AVP_LIST
        for keyValue in keyValues:
            # if ATTRIBUTE is category then put the value into label
              if keyValue['ATTRIBUTE'] == 'entity_category':
                  labels = keyValue['VALUE'].split(',')
                  labels = tuple(labels)
                  #print len(labels)
              else:
                  key_values[keyValue['ATTRIBUTE']] = keyValue['VALUE']
        # labels is tuple  and key_values is a dict
        # use with which can create a node
        node = Node()
        neoGraph.create(node)
        node.__init__(*labels,**key_values)
        node.push() 
        createIndexofNode(neoGraph,node)
        autoBuildRelationShip(neoGraph,node)  
开发者ID:zhu-dq,项目名称:Neo4jCPP,代码行数:36,代码来源:newOne.py

示例2: make_node

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import push [as 别名]
def make_node(nodetype,uid,name,properties=None,property_key="id"):
    node = None
    if graph.find_one(nodetype,property_key='id', property_value=uid) == None:
        print("Creating %s:%s, %s" %(nodetype,name,uid))
        timestamp = graph.cypher.execute("RETURN timestamp()").one
        node = Node(nodetype, name=name,id=uid,creation_time=timestamp,last_updated=timestamp)
        graph.create(node)
        if properties != None:
            for property_name in properties.keys():
                node.properties[property_name] = properties[property_name]
            node.push()
    return node
开发者ID:rwblair,项目名称:cogat-docker,代码行数:14,代码来源:migrate_database.py

示例3: create

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import push [as 别名]
 def create(self,name,properties=None,property_key="id"):
     '''create will create a new node of nodetype with unique id uid, and properties
     :param uid: the unique identifier
     :param name: the name of the node
     :param properties: a dictionary of properties with {field:value} for the node
     '''
     node = None
     uid = generate_uid(self.name) # creation also checks for existence of uid
     if graph.find_one(self.name,property_key='id',property_value=uid) == None:
         timestamp = graph.cypher.execute("RETURN timestamp()").one
         node = NeoNode(self.name, name=name,id=uid,creation_time=timestamp,last_updated=timestamp)
         graph.create(node)
         if properties != None:
             for property_name in properties.keys():
                 node.properties[property_name] = properties[property_name]
             node.push()
     return node
开发者ID:rwblair,项目名称:cogat-docker,代码行数:19,代码来源:query.py

示例4: saveComponent

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import push [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)
开发者ID:sirolf2009,项目名称:HardMatch,代码行数:20,代码来源:IParseSave.py

示例5: upload_tweets

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import push [as 别名]
def upload_tweets(tweets):
    for t in tweets:
        u = t["user"]
        e = t["entities"]

        tweet = Node("Tweet", id=t["id"])
        graph.merge(tweet)
        tweet["text"] = t["text"]
        tweet.push()

        user = Node("User", username=u["screen_name"])
        graph.merge(user)

        graph.merge(Relationship(user, "POSTS", tweet))

        for h in e.get("hashtags", []):
            hashtag = Node("Hashtag", name=h["text"].lower())
            graph.merge(hashtag)
            graph.merge(Relationship(hashtag, "TAGS", tweet))

        for m in e.get('user_mentions', []):
            mention = Node("User", username=m["screen_name"])
            graph.merge(mention)
            graph.merge(Relationship(tweet, "MENTIONS", mention))

        reply = t.get("in_reply_to_status_id")

        if reply:
            reply_tweet = Node("Tweet", id=reply)
            graph.merge(reply_tweet)
            graph.merge(Relationship(tweet, "REPLY_TO", reply_tweet))

        ret = t.get("retweeted_status", {}).get("id")

        if ret:
            retweet = Node("Tweet", id=ret)
            graph.merge(retweet)
            graph.merge(Relationship(tweet, "RETWEETS", retweet))
开发者ID:KoenR3,项目名称:neo4j-jupyter,代码行数:40,代码来源:twitter.py

示例6: addNode

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import push [as 别名]
def addNode(neoGraph,jsonNode):
    respCmtJson = jsonNode.replace("'", "\"");
    # turn string to json
    js = simplejson.loads(respCmtJson)
    # lable  and key_values
    labels = []
    key_values = {}
    #put ID into the dict
    key_values['ID'] = js['ID']
    keyValues = js['AVP_LIST']
    # for all key_values in the AVP_LIST
    for keyValue in keyValues:
    # if ATTRIBUTE is category then put the value into label
        if keyValue['ATTRIBUTE'] == 'entity_category':
            labels = keyValue['VALUE'].split(',')
            labels = tuple(labels)
        else:
            key_values[keyValue['ATTRIBUTE']] = keyValue['VALUE']
    # labels is tuple  and key_values is a dict
    node = Node()
    neoGraph.create(node)
    node.__init__(*labels,**key_values)
    node.push() 
开发者ID:zhu-dq,项目名称:Neo4jCPP,代码行数:25,代码来源:newOne.py

示例7: saveComponent

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import push [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)
开发者ID:sirolf2009,项目名称:HardMatch,代码行数:39,代码来源:AlternateCrawler.py

示例8: Graph

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import push [as 别名]
graph = Graph()
s = 0
f = open(r"G:\knowledge graph\search_Knowledge v0.2\web_crawler\resource\man2.json","r")
for line in f:
    lineone = line
    s = s+1
    #if s <= 3:
        #continue
    print s
    js = None
    try:
        js = json.loads(lineone)
        for i in js:
            place = Node("Man_name",name = i)
            graph.create(place)   
            jDict = js[i]
            for j in jDict:
                property1 = j.split()
                property1 = ''.join(property1)                  
                string = json.dumps(jDict[j],ensure_ascii=False)
                place.properties[property1] =string.replace("\"","")
            place.push()
    except Exception,e:
        print 'bad Line'
f.close()





开发者ID:youjiajia,项目名称:Knowledge,代码行数:27,代码来源:getPlacetoJson.py

示例9: print

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import push [as 别名]
      if(wayname != "" and isHighway == True):
        # check if way needs to be added to the database
        street = g.find_one("Street", "nameslug", wayname)
        if(street == None):
          print('add ' + wayname)
          
          # create street in database
          street = Node("Street", nodeids=waynodes, nameslug=wayname)
          tx = g.begin()
          tx.create(street)
          tx.commit()
        
        else:
          # know this street, add the way id
          street['nodeids'] = street['nodeids'] + waynodes
          street.push()

        # now add relationships to nodes in the way
        for node in waynodes:
          if(node in knownnodes):
            streetnames = g.run("MATCH (n:Street) WHERE {nodeid} IN n.nodeids RETURN n.nameslug LIMIT 25", nodeid=node)
            for streetrecord in streetnames:
              streetname = streetrecord['n.nameslug']
              if streetname == wayname:
                continue
              print('matching ' + streetname + ' and ' + wayname)
              street2 = g.find_one("Street", "nameslug", streetname)
              if street2 is None:
                continue
              intersect = Relationship(street, "MEETS", street2)
              intersect2 = Relationship(street2, "MEETS", street)
开发者ID:mapmeld,项目名称:graph,代码行数:33,代码来源:store-osm.py

示例10: Graph

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import push [as 别名]
graph = Graph()

# Nodes and relationships
from py2neo import Node, Relationship
alice = Node("Person", name="Alice")
bob = Node("Person", name="Bob")
alice_knows_bob = Relationship(alice, "KNOWS", bob)
graph.create(alice_knows_bob)

# Pushing and pulling
# To illustrate synchronisation, let’s give Alice and Bob an 
# age property each. 
alice.properties["age"] = 33
bob.properties["age"] = 44
alice.push()
bob.push()

# Previous versions of py2neo have synchronised data between 
# client and server automatically, such as when setting a single 
# property value. Py2neo 2.0 will not carry out updates to client 
# or server objects until this is explicitly requested.

# Here, we add a new property to each of the two local nodes and 
# push the changes in turn. This results in two separate HTTP calls 
# being made to the server which can be seen more clearly with the 
# debugging function, watch:
from py2neo import watch
watch("httpstream")
alice.push()
bob.push()
开发者ID:matthiaskoenig,项目名称:neo4sbml,代码行数:32,代码来源:py2neo_example.py

示例11: Graph

# 需要导入模块: from py2neo import Node [as 别名]
# 或者: from py2neo.Node import push [as 别名]
'''
    Script to create some sample nodes and edges, purely for illustration purposes. Does not align with the
    nodes, edges and properties in other scripts.
'''

from py2neo import Graph
graph = Graph()
from py2neo import Node, Relationship
magdalena = Node("Artist", name="Abakanowicz, Magdalena", id=10093, gender="Female", birthYear=1930)
polska=Node("Place", name="Polska")
magdalena_born_in_polska = Relationship(magdalena, "BORN_IN", polska)
graph.create(magdalena_born_in_polska)
polska.properties["id"]="Polska"
polska.push()
magdalena_born_in_polska.properties["date"]=1930

magdalena_born_in_polska.push()
t12979 = Node("Artwork", title="Abakan Red", date=1969, acno="T12979", id=102938)
magdalena_contributed_to_t12979 = Relationship(magdalena, "CONTRIBUTED_TO", t12979)
graph.create(magdalena_contributed_to_t12979)
metal = Node("Medium", name="metal")
sisal = Node("Medium", name="sisal")
abakan_made_of_metal = Relationship(t12979, "MADE_OF", metal)
abakan_made_of_sisal = Relationship(t12979, "MADE_OF", sisal)
graph.create(abakan_made_of_metal, abakan_made_of_sisal)

cities = Node("Place Types", name="cities, towns, villages (non-UK)")
countries = Node("Place Types", name="countries and continents")
abakan = Node("Place", name="Abakan")
abakan = Node("Place", name="Russia, Khakassia")
abakan = Node("Place", name="Abakan")
开发者ID:dlarkinc,项目名称:tate2neo,代码行数:33,代码来源:Create_graph.py


注:本文中的py2neo.Node.push方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。