Python3 impyla 连接 hiveserver2
简介:
接到一个任务,需要从 hive 中读取数据,生成报表。
官方文档提供了一个使用 pyhs2 连接 hive 的例子,这本来很好的嘛。
结果去 Github:https://github.com/BradRuderman/pyhs2 瞅了一眼,很遗憾 pyhs2 项目已经不维护了。
不过,提供了两个很不错的替代项目:https://github.com/cloudera/impyla、https://github.com/dropbox/PyHive
终于绕到今天的主角了~
一、HiveServer2
shell > cd /usr/local/apache-hive-2.3.-bin shell > sh bin/hiveserver2 start > logs/beeline.log >& & # 这就启动了,停止的话好像必须 kill pid。
二、impyla
# 安装依赖
shell > yum -y install gcc gcc-c++ cyrus-sasl-devel cyrus-sasl-plain # 创建虚拟环境
shell > virtualenv --no-site-packages -p python3 venv # 启用虚拟环境
shelll > source venv/bin/activate (venv) shell > python -V
Python 3.6. # 安装 impyla 及所需依赖包
(venv) shell > pip install ipython six bit_array thriftpy thrift_sasl==0.2. sasl impyla (venv) shell > ipython In []: from impala.dbapi import connect In []: conn = connect(host="192.168.10.45", port=, database="logsdb", auth_mechanism="PLAIN") In []: cur = conn.cursor() In []: cur.execute("select count(*) from log_bftv_api") In []: cur.fetchone()
Out[]: (,) In []: conn.close() # 程序查出了 hive table log_bftv_api 中总共有 条数据。 # 其中,连接配置中 auth_mechanism 的值由 hive-site.xml 配置文件中 hive.server2.authentication 配置项指定。 # PLAIN 代表不启用认证,也就是 hive.server2.authentication 的默认值:NONE。
Python3 impyla 连接 hiveserver2的更多相关文章
- Python3实现连接SQLite数据库的方法
本文实例讲述了Python3实现连接SQLite数据库的方法,对于Python的学习有不错的参考借鉴价值.分享给大家供大家参考之用.具体方法如下: 实例代码如下: ? 1 2 3 4 5 6 7 8 ...
- 由“Beeline连接HiveServer2后如何使用指定的队列(Yarn)运行Hive SQL语句”引发的一系列思考
背景 我们使用的HiveServer2的版本为0.13.1-cdh5.3.2,目前的任务使用Hive SQL构建,分为两种类型:手动任务(临时分析需求).调度任务(常规分析需求),两者均通过我们的 ...
- python3.5连接oracle数据及数据查询
今天心血来潮研究下用python连接oracle数据库,看了一下demo,本以为很简单,从操作到成功还是有点坎坷,这里分享给大家,希望为后面学习的童鞋铺路. 一.首先按照cx_Oracle 二:在py ...
- 用Java代码通过JDBC连接Hiveserver2
1.在终端启动hiveserver2#hiveserver2 2.使用beeline连接hive另外打开一个终端,输入如下命令(xavierdb必须是已经存在的数据库)#beeline -u jdbc ...
- 【原创】大叔经验分享(38)beeline连接hiveserver2报错impersonate
beeline连接hiveserver2报错 Error: Could not open client transport with JDBC Uri: jdbc:hive2://localhost: ...
- python3.4连接mysql5.7数据库增删改查
#!/usr/bin/env python # -*- coding:utf-8 -*- # __author__ = "blzhu" """ pyt ...
- 通过JDBC连接HiveServer2
如果通过JDBC连接HiveServer2时提示:User: hive is not allowed to impersonate hive,需要在core-site.xml中新增如下配置: hado ...
- python3.4连接mysql数据库的方法
python3.4连接mysql数据库的方法 发布时间:2014-08-04编辑:www.jbxue.com 本文介绍了python3.4连接mysql数据库的方法,在python3.4中不能用mys ...
- python3.6 连接mysql数据库问题
最近有个项目欲安装MySQL-python/1.2.5一直失败. 环境: win7 python3.6.2 报错信息如下: Creating library build\temp.win32-3.6\ ...
随机推荐
- 针对 FastAdmin 2018-01-19 号的升级 SQL (废)
FastAdmin 在 2018-01-19 升级增加了以下功能. 新增前台会员模块和API会员模块 新增后台会员管理.会员规则和会员分组管理 新增短信发送的行为事件 新增前台Token.短信.日志模 ...
- 转jmeter --JDBC请求
做JDBC请求,首先要了解这个JDBC对象是什么,然后寻找响应的数据库连接URL和数据库驱动. 数据库URL:jdbc:sqlserver://200.99.197.190:1433;database ...
- 4G的添加
(ZTE 中兴 ME3760_V2 ) 1. 复制myLte文件到相关目录,设置权限为755 2.修改openwrt1407/package/base-files/files/etc/rc.local ...
- javascript 获取视口的高度和宽度
//获取视口的高度和宽度. function windowHeight() { var de = document.documentElement; return self.innerHeight|| ...
- android开发常用组件【持续更新中。。。】
UI相关 图片 Android-Universal-Image-Loader:com.nostra13.universalimageloader:异步加载.缓存.显示图片 ImageLoader:co ...
- 【pushlet学习】具体实战
业务需求: 1. 前端界面需要实时显示空调.照明等设备的状态, 如:空调电压.空调电流.光照强度等,这些量每一个称作一个测点: 2. 不同的用户登录系统后,用户只能看到自己设备的运行状态,而看不到其他 ...
- bzoj1050 旅行
Description 给你一个无向图,N(N<=500)个顶点, M(M<=5000)条边,每条边有一个权值Vi(Vi<30000).给你两个顶点S和T,求一条路径,使得路径上最大 ...
- tcp端口检测
# coding=utf-8 import sys import socket import re def check_server(address, port): s = socket.socket ...
- springMVC学习(7)-springMVC校验
一.校验理解: 对于安全要求较高点建议在服务端进行校验. 控制层conroller:校验页面请求的参数的合法性.在服务端控制层conroller校验,不区分客户端类型(浏览器.手机客户端.远程调用) ...
- 利用python,简单的词语纠错
利用python,编写一个简单的词语纠正修改器. 原文:http://norvig.com/spell-correct.html #!/usr/bin/env python # coding=utf- ...