到StellarDB的Python接口

PyStellarDB的Python项目详细描述


PystlarDB公司

PyStellarDB是一个Python API,用于执行Transwarp exepended OpenCypher(TEoC)和配置单元查询。 它基于PyHive(https://github.com/dropbox/PyHive

使用

普通模式(未配置安全性)

frompystellardbimportstellar_hiveconn=stellar_hive.StellarConnection(host="localhost",port=10000,graph_name='pokemon')cur=conn.cursor()cur.execute('config query.lang cypher')cur.execute('use graph pokemon')cur.execute('match p = (a)-[f]->(b) return a,f,b limit 1')printcur.fetchall()

LDAP模式

^{pr2}$

Kerberos模式

# Make sure you have the correct realms infomation about the KDC server in /etc/krb5.conf# Make sure you have the correct keytab file in your environment# Run kinit command:# In Linux: kinit -kt FILE_PATH_OF_KEYTABL PRINCIPAL_NAME# In Mac: kinit -t FILE_PATH_OF_KEYTABL -f PRINCIPAL_NAMEfrompystellardbimportstellar_hiveconn=stellar_hive.StellarConnection(host="localhost",port=10000,kerberos_service_name='hive',auth='KERBEROS',graph_name='pokemon')cur=conn.cursor()cur.execute('config query.lang cypher')cur.execute('use graph pokemon')cur.execute('match p = (a)-[f]->(b) return a,f,b limit 1')printcur.fetchall()

执行配置单元查询

frompystellardbimportstellar_hive# If `graph_name` parameter is None, it will execute a Hive query and return data just as PyHive doesconn=stellar_hive.StellarConnection(host="localhost",port=10000,database='default')cur=conn.cursor()cur.execute('SELECT * FROM default.abc limit 10')

依赖关系

必需:

  • Python 2.7+/Python 3

系统SASL

不同的系统需要安装不同的包来支持SASL 在英皮拉。关于如何在不同发行版上安装包的一些示例 跟随。在

Ubuntu:

apt-get install libsasl2-dev libsasl2-2 libsasl2-modules-gssapi-mit
apt-get install python-dev gcc              #Update python and gcc if needed

RHEL/CentOS公司:

yum install cyrus-sasl-md5 cyrus-sasl-plain cyrus-sasl-gssapi cyrus-sasl-devel
yum install gcc-c++ python-devel.x86_64     #Update python and gcc if needed

要求

使用安装

  • pip install 'pystellardb[hive]',用于配置单元接口。在

PyHive与

测试

在路上

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
maven字段#getGenericType()抛出java。lang.TypeNotPresentException   用java绘制三角形的几何图形   java无法下载主题和发件人地址(rediff)   java如何使代码线程安全   java在尝试转换FileInputStream中的文件时,我遇到了一个FileNotFound异常   java Moxy和Jackson如何将Json映射到Pojo   在foreach循环中使用BufferedWriter生成新行的java问题   java为什么我的测试在单次执行中运行时间小于1秒,而在maven构建中运行时间大于20秒?   java如何显示下载附件的进度条   了解java rmi的良好实践   .net可以将Java portlet嵌入ASP。网页?   循环如何多次执行Java方法?   java如何确保用户输入在给定的有效范围内?   java单元测试定理   java如何在IntelliJ上运行外部构建项目?   JAVA:试图编写一个检查字符串是否为数字的方法。总是返回错误   javahadoop将特定键的所有map方法生成的所有值都发送到一个reduce方法,对吗?   在java中读取和使用文件