python 操作gremlin
安装 我这用的是python3 ,但是python2跟这个差不多 我都试了
pip3 install gremlinpython
下面两种连接方式,看想用那种了,性能什么的都没测试
1.python代码请求
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 端口号
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.自己用过的语句
###
#sql 查询添加的数据-id
###
# a=g.V().has("company_n","上海美都管理咨询有限公司第一分公司").valueMap().toList()
#g.V().has("company_n","上海美都管理咨询有限公司第一分公司").valueMap(True).toList()#查询所有数据
#g.V().has("company_n","上海美都管理咨询有限公司第一分公司").id() # print(a)###
#获取所有点的id list
###
# bs=g.V().toList()
# print(bs)###
#遍历所有数据
###
# 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得数据
#### 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.E().group().by(label).by(count())
以后慢慢补
python 操作gremlin相关推荐
- python操作word文档(python-docx)
python操作word文档(python-docx) 1. 效果图 1.1 python-docx文档标题段落(等级.加粗.斜体.居中)效果图 1.2 python-docx字体(加粗.斜体.居中. ...
- Python操作 RabbitMQ、Redis、Memcache、SQLAlchemy
Memcached Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的速度 ...
- Python 操作 MongoDB 数据库!
作者 |黄伟呢 来源 |数据分析与统计学之美 MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的. 先来看看MySQL与MongoDB 概念区别 ...
- python操作yaml的方法详解
这篇文章主要为大家介绍了python操作yaml的方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,希望能够给你带来帮助 一.参考链接 https://pyyaml.org/wiki/PyYAM ...
- python连接excel存放数据_有了这篇python操作Excel学习笔记,以后储存数据 办公很轻松!...
最近在做一些数据处理和计算的工作,因为数据是以.csv格式保存的,因此刚开始直接用Excel来处理.但是做着做着发现重复的劳动其实并没有多大的意义,于是就想着写个小工具帮着处理.以前正好在一本书上看到 ...
- job for nginx.service failed_用Python操作Kubernetes的Job
关于Kubernetes的Python SDK,几乎只有官方项目的examples.关于Job的基本增删改查操作,可以参考job_crud.py.但是,这只是基本用法,缺乏一些实用细节. 本文给出Py ...
- python怎么玩pdf_最全总结!聊聊 python 操作PDF的几种方法
作者:陈熹 来源:早起Python 一.前言 大家好,有关Python操作PDF的案例之前已经写过一个PDF批量合并,这个案例初衷只是给大家提供一个便利的脚本,并没有太多讲解原理,其中涉及的就是PDF ...
- python操作neo4j
python操作neo4j 先安装neo4j的库: pip install neo4j 测试代码: from neo4j import GraphDatabasedriver = GraphDatab ...
- python操作MariaDB
先安装库: python3 -m pip install PyMySQL 代码如下: import pymysql conn = pymysql.connect(host='127.0.0.1', u ...
最新文章
- tf.variance_scaling_initializer() tensorflow学习:参数初始化
- 阿里巴巴CEO马云最新超经典哲学语录
- 信息处理进入了计算机领域,信 息 处 理 进 入 了 计 算 机 领 域 ,实 质 是 进 入 了()的 领 域 。...
- python科学计算三剑客_《Python数据分析三剑客:Pandas、Numpy、Matplotlib》专题
- juqery-筛选器-找前后上下
- 全盘镜像只还原c盘有影响么_如何正确的清理C盘
- 关于testNG和JUnit的对比
- 代码走查(codereview)如何执行才能提升代码质量
- 秒搜编程好书 就用这个Python写的爬虫网站
- Android中英文切换
- JAVA实现饭店点菜系统详解
- echarts条形图
- Linux查看网卡是rdma,Chelsio RDMA Block设备驱动测试
- 全球及中国LCP行业发展动态与投资趋势分析报告2022~2028年
- 拉斯维加斯国际黑客大会 本周开战
- javascript设计模式-原型模式(prototype pattern)
- MEMS VOA光衰减器的工作原理
- Verilog基本语法之概述(一)
- 25岁,毕业一年辞职自学转行嵌入式是否可行?
- 复变函数与积分变换系列(一) - 复变函数与解析函数