pyhive的基本使用
安装
yum -y install cyrus-sasl cyrus-sasl-devel cyrus-sasl-lib # 解决报错:sasl/sasl.h: No such file or directory
pip install sasl
pip install thrift
pip install thrift_sasl
pip install pyhive
pyhive的两种基本使用方式:同步方式和异步方式:
1、同步DB API
from pyhive import presto
cursor = presto.connect('localhost').cursor()
cursor.execute('SELECT * FROM my_awesome_data LIMIT 10')
print cursor.fetchone()
print cursor.fetchall()
2、异步DB API
from pyhive import hive
from TCLIService.ttypes import TOperationState
cursor = hive.connect('localhost').cursor()
cursor.execute('SELECT * FROM my_awesome_data LIMIT 10', async=True) status = cursor.poll().operationState
while status in (TOperationState.INITIALIZED_STATE, TOperationState.RUNNING_STATE):
logs = cursor.fetch_logs()
for message in logs:
print(message)
# 可随时取消异步查询
# cursor.cancel()
status = cursor.poll().operationState print(cursor.fetchall())
pyhive的基本使用的更多相关文章
- pyhive 连接 Hive 时错误
一.User: xx is not allowed to impersonate xxx' 解决办法:修改 core-site.xml 文件,加入下面的内容后重启 hadoop. <proper ...
- Anaconda安装sasl,thrift,thrift-sasl,PyHive连接Hive
一.安装sasl 安装失败,前往:https://www.lfd.uci.edu/~gohlke/pythonlibs/#sasl下载对应自己python版本的sasl 本地安装: 二.安装thrif ...
- 使用PyHive操作Hive
使用PyHive操作Hive 废话 搜了一下,看到了StackOverFlow的回答,试了一下前两个方案,感觉第二个更简洁,这里记录一下,更详细的见参考. 安装依赖 pip install sasl ...
- pyhive -- thrift.transport.TTransport.TTransportException: TSocket read 0 bytes
Pyhive 远程连接hive出现问题: from pyhive import hive import pandas as pd #Create Hive connection conn = hive ...
- pyhive client连接hive报错处理:Could not start SASL
本来一切就绪,镜像里已安装如下主要的pip包. pyhive configparser pandas hdfs thrift sqlparse sasl thrift-sasl 但,使用pyhive ...
- python3.7 利用pyhive 连接上hive(亲测可用)
来python爬虫中,经常会遇到数据的存储问题,如果有大量数据,hive存储是个不错的选择. 那么python如何来连接hive呢?网上有各种教程但是都不是很好用,亲自测试pyhive可用 要求:可用 ...
- pyhive
from pyhive import hiveimport pandas as pdimport numpy as npclass myhive(): def __init__(self,hos ...
- pyhive连接hive(失败)
一.安装pyhive pip install sasl(需要来下载至本地安装:https://download.lfd.uci.edu/pythonlibs/q4hpdf1k/sasl-0.2.1-c ...
- 初识python 之 离线搭建pyhive环境(含python3安装)
系统版本: centos6.5 python版本:python3.6.8 相关包存放目录:software 注意:以下操作需要用到root权限 安装python3 root操作 cd /lzh/sof ...
随机推荐
- 编写自己的代码库(css3常用动画的实现)
编写自己的代码库(css3常用动画的实现) 1.前言 在月初的时候,发了CSS3热身实战--过渡与动画(实现炫酷下拉,手风琴,无缝滚动).js的代码库也发过两次,两篇文章.之前也写了css3的热身实战 ...
- Java系列教程-MyBatis 3.5.5 教程目录
MyBatis 3.5.5 初级教程目录 可参考MyBatis的官方文档也比较清楚 https://mybatis.org/mybatis-3/zh/getting-started.html 代码 目 ...
- IdentityServer4是什么
1 什么是IdentityServer4? IdentityServer4是用于ASP.NET Core的OpenID Connect和OAuth 2.0框架. 2 什么是OAuth 2.0? OAu ...
- Starting Tomcat v9.0 Server at localhost' has encountered a problem
•问题描述 在通过 Eclipse 打开 Tomcat 时报错: •解决方案 找到 Tomcat 的安装位置,打开 tomcat\bin 目录,找到 shutdown.bat,手动关闭 tomcat: ...
- 第28 章 : 理解容器运行时接口 CRI
理解容器运行时接口 CRI CRI 是 Kubernetes 体系中跟容器打交道的一个非常重要的部分.本文将主要分享以下三方面的内容: CRI 介绍 CRI 实现 相关工具 CRI 介绍 在 CRI ...
- 安卓安装kali linux之Termux
解决安装kali无模组问题 https://blog.csdn.net/weixin_44690490/article/details/108599693?utm_source=app 步骤 1.获取 ...
- python基础(补充):列表生成器
列表推导式是Python构建列表(list)的一种快捷方式,可以使用简洁的代码就创建出一个列表. 举个例子,要生成list [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]可以用list ...
- Leedcode算法专题训练(栈和队列)
1. 用栈实现队列 232. Implement Queue using Stacks (Easy) Leetcode / 力扣 class MyQueue { Stack<Integer> ...
- JVM(一)内存结构
今日开篇 什么是JVM 定义 Java Virtual Machine,JAVA程序的运行环境(JAVA二进制字节码的运行环境) 好处 一次编写,到处运行 自动内存管理,垃圾回收机制 数组下标越界检查 ...
- mvnw 找不到或无法加载主类,找不到符号,类
如果你出现"找不到或无法加载主类"的问题,很有可能是maven的问题,你可以尝试一下这种办法: 问题:关于maven什么东西都没动,上午可能运行都好好的,下午可能就出现了这个问题, ...