到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
测试
在路上
- 项目
标签: