pyopenLooKeng 是 openLooKeng 的python DB-API客户端
TOPIC_ID:62, TEAM_ID:1154698365, TEAM_NAME:穿梭在银河的火箭队.
OpenLooKeng采用REST通信,包括CLI、JDBC与 Coordinator, Coordinator 与 Worker。Python client也可以使用REST通信,将Statement 按照 OpenLooKeng求封装成REST请求,发送恰 Coordinator执行,包含以下请求:
同时,OpenLooKeng需要提供加密和认证功能,需要支持HTTPS加密以及Basic与Kerberos认证。 Python客户端作为OpenLooKeng的模块,需要符合OpenLooKeng的开发规范,同时客户端需要经过充分测试,单元测试覆盖率需要符合OpenLooKeng的要求,并且功能完成,能够正常访问OpenLooKeng的业务。
PEP-249 DB-API为不同的数据库提供了一致的访问接口,比如我们可以很轻松地将访问的数据库从Mysql等移植到OpenLooKeng上,只需要进行少量的代码更改。
Connnection
Cursor
git clone https://gitee.com/openeuler2020/team-1154698365.git && cd team-1154698365
pip install -r requirements.txt
python setup.py install
from pyopenLooKeng import connections
conn = connections.connect(host='host', port=8080, catalog='system', schema='runtime')
print(conn.cluster())
print(conn.query())
# ...
cur = conn.cursor()
cur.execute("SHOW TABLES")
res = cur.fetchall()
print(res)
# (('nodes',), ('queries',), ('tasks',), ('transactions',))
from pyopenLooKeng import connections
conn = connections.connect(host='host', port=8080, catalog='system', schema='runtime',
protocol="https",https_verify="trust")
print(conn.cluster())
print(conn.query())
# ...
cur = conn.cursor()
cur.execute("SHOW TABLES")
res = cur.fetchall()
print(res)
# (('nodes',), ('queries',), ('tasks',), ('transactions',))
from pyopenLooKeng import connections, auth
myAuth = auth.BasicAuthentication(username='user', password='password')
# Kerberos authentication can also be used
conn = connections.connect(host='host', port=8080, catalog='system', schema='runtime',
protocol="https", https_verify="trust", auth=myAuth)
print(conn.cluster())
print(conn.query())
# ...
cur = conn.cursor()
cur.execute("SHOW TABLES")
res = cur.fetchall()
print(res)
# (('nodes',), ('queries',), ('tasks',), ('transactions',))
py.test test_xxx.py
命令进行测试我们增加了新的压力测试的代码,并且对单机的OepnLooKeng进行了不同进程池大小进行200次mysql查询的测试。 机器性能:2核 4GB 5Mbps 操作系统:Ubuntu 18.04 LTS 进程数由小到大递增
结果:
进程池大小 | 查询最小用时(s) | 平均用时 | 最长用时 | 总用时 |
---|---|---|---|---|
4 | 0.5312347412109375 | 0.7557646048069 | 1.1501729488372803 | 151.15292096138 |
8 | 0.5318071842193604 | 0.8178671360015869 | 1.2911303043365479 | 163.57342720031738 |
16 | 0.5414032936096191 | 0.962301059961319 | 1.4733026027679443 | 192.4602119922638 |
32 | 0.5549044609069824 | 1.7005435049533844 | 3.0190680027008057 | 340.1087009906769 |
64 | 0.8101632595062256 | 3.232089376449585 | 10.673005104064941 | 646.417875289917 |
96 | 1.0760657787322998 | 5.666961643695831 | 12.587688684463501 | 1133.3923287391663 |
128 | 1.1646084785461426 | 7.965008200407028 | 13.491569519042969 | 1593.0016400814056 |
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。