日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > python >内容正文

python

python 操作gremlin

發(fā)布時(shí)間:2024/1/1 python 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python 操作gremlin 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

安裝 我這用的是python3 ,但是python2跟這個(gè)差不多 我都試了

pip3 install gremlinpython

下面兩種連接方式,看想用那種了,性能什么的都沒(méi)測(cè)試

1.python代碼請(qǐng)求

graph = Graph() g = graph.traversal().withRemote(DriverRemoteConnection('ws://hosts:port/gremlin','g')) g.addV('god').property('name', 'yuxj').property('age', 111).next() a=g.V().has('name','yuxj').valueMap().toList() print (a)

hosts:ip地址 port 端口號(hào)

2.提交sql

from gremlin_python.driver import client client = client.Client('ws://192.168.1.15:8182/gremlin','g') ### #sql添加邊界得label ### gsql="mgmt = graph.openManagement()\n"\"create = mgmt.makeEdgeLabel('create').multiplicity(MULTI).make()\n" \"mgmt.commit()\n" client.submit(gsql)

sql就是gremlin的sql

3.自己用過(guò)的語(yǔ)句

### #sql 查詢添加的數(shù)據(jù)-id ### # a=g.V().has("company_n","上海美都管理咨詢有限公司第一分公司").valueMap().toList() #g.V().has("company_n","上海美都管理咨詢有限公司第一分公司").valueMap(True).toList()#查詢所有數(shù)據(jù) #g.V().has("company_n","上海美都管理咨詢有限公司第一分公司").id() # print(a)### #獲取所有點(diǎn)的id list ### # bs=g.V().toList() # print(bs)### #遍歷所有數(shù)據(jù) ### # for b in bs: # print(g.V(b).valueMap().toList())# q=g.V(b).values('company_n').toList()# if q:# print (q)# else:# q = g.V(b).values('name').toList()# print(q) # c=g.V().has('name','yuxj9').valueMap().toList() # print(c) # d=g.V().hasLabel("1").count().toList() # print (d) # client.close()### #sql 添加邊界 ####esql="g.V().has('name','marko').as('m').V().has('name','lop').as('l').addE('create').from('m')" #client.submit(esql)### #where 查看label 為company 和representative得數(shù)據(jù) #### A=g.V().where(hasLabel('company').or_().hasLabel('representative')).valueMap(True).toList() # print (A)#g.V().has('chair_id', within('%s')).as_('A').V().has('repren_id', within('%s')).addE('法人').from_('A'); # from gremlin_python.process.traversal import T # from gremlin_python.process.traversal import Order # from gremlin_python.process.traversal import Cardinality # from gremlin_python.process.traversal import Column # from gremlin_python.process.traversal import Direction # from gremlin_python.process.traversal import Operator # from gremlin_python.process.traversal import P # from gremlin_python.process.traversal import Pop # from gremlin_python.process.traversal import Scope # from gremlin_python.process.traversal import Barrier # a=g.V().has("company_n",P.textContent("分公司")).valueMap() # print (a) ######## ##查看邊界和個(gè)數(shù) #### #g.E().group().by(label).by(count())

以后慢慢補(bǔ)

總結(jié)

以上是生活随笔為你收集整理的python 操作gremlin的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。