安装

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的基本使用的更多相关文章

  1. pyhive 连接 Hive 时错误

    一.User: xx is not allowed to impersonate xxx' 解决办法:修改 core-site.xml 文件,加入下面的内容后重启 hadoop. <proper ...

  2. Anaconda安装sasl,thrift,thrift-sasl,PyHive连接Hive

    一.安装sasl 安装失败,前往:https://www.lfd.uci.edu/~gohlke/pythonlibs/#sasl下载对应自己python版本的sasl 本地安装: 二.安装thrif ...

  3. 使用PyHive操作Hive

    使用PyHive操作Hive 废话 搜了一下,看到了StackOverFlow的回答,试了一下前两个方案,感觉第二个更简洁,这里记录一下,更详细的见参考. 安装依赖 pip install sasl ...

  4. pyhive -- thrift.transport.TTransport.TTransportException: TSocket read 0 bytes

    Pyhive 远程连接hive出现问题: from pyhive import hive import pandas as pd #Create Hive connection conn = hive ...

  5. pyhive client连接hive报错处理:Could not start SASL

    本来一切就绪,镜像里已安装如下主要的pip包. pyhive configparser pandas hdfs thrift sqlparse sasl thrift-sasl 但,使用pyhive ...

  6. python3.7 利用pyhive 连接上hive(亲测可用)

    来python爬虫中,经常会遇到数据的存储问题,如果有大量数据,hive存储是个不错的选择. 那么python如何来连接hive呢?网上有各种教程但是都不是很好用,亲自测试pyhive可用 要求:可用 ...

  7. pyhive

    from pyhive import hiveimport pandas as pdimport numpy as npclass myhive():    def __init__(self,hos ...

  8. pyhive连接hive(失败)

    一.安装pyhive pip install sasl(需要来下载至本地安装:https://download.lfd.uci.edu/pythonlibs/q4hpdf1k/sasl-0.2.1-c ...

  9. 初识python 之 离线搭建pyhive环境(含python3安装)

    系统版本: centos6.5 python版本:python3.6.8 相关包存放目录:software 注意:以下操作需要用到root权限 安装python3 root操作 cd /lzh/sof ...

随机推荐

  1. Git详解和Github的使用

    Git和Github的概念: Git是分布式版本管理系统,简单说就是一个软件,用于记录一个或若干文件内容变化,以便将来查阅特定版本修订情况的软件. Github是一个为用户提供Git服务的网站,简单说 ...

  2. 从RocketMQ的Broker源码层面验证一下这两个点

    本篇博客会从源码层面,验证在RocketMQ基础概念剖析,并分析一下Producer的底层源码中提到的结论,分别是: Broker在启动时,会将自己注册到所有的NameServer上 Broker在启 ...

  3. 在Python中创建M x N的数组

    在Python中创建M x N的数组 一般有三种方法: 列表乘法 dp = [[0] * n] * m for 循环 dp= [[0 for _ in range(n)] for _ in range ...

  4. RabbitMQ 入门 (Go) - 1. 简介和安装

    Message Broker(消息代理) 维基百科对 Message Broker 的定义是:Message broker 是一种中介程序模块,它把消息从发送方的正式消息传递协议转化为接收方的正式消息 ...

  5. 单链表c语言实现的形式

    包括初始化,创建,查询,长度,删除,清空,销毁等操作 代码如下: #include<stdio.h> #include<stdlib.h> //定义单链表的数据类型 typed ...

  6. C++并发与多线程学习笔记--线程之间调度

    condition_variable wait() notify_one notify_all condition_variable 条件变量的实际用途: 比如有两个线程A和B,在线程A中等待一个条件 ...

  7. CentOS 7.6部署Vue + SrpingBoot + MySQL单体项目

    对于独立的项目(前端.后台单体服务.数据库),部署到新服务器上时,常常需要繁琐的配置与环境安装,这里介绍Centos 7.6下如何搭建基于Docker的环境,以及如何使用docker部署一套Vue + ...

  8. leetcode 刷题(数组篇)152题 乘积最大子数组 (动态规划)

    题目描述 给你一个整数数组 nums ,请你找出数组中乘积最大的连续子数组(该子数组中至少包含一个数字),并返回该子数组所对应的乘积. 示例 1: 输入: [2,3,-2,4] 输出: 6 解释: 子 ...

  9. Linux 查看GPU状态

    Linux 查看GPU状态 nvidia-smi nvidia-smi是NVIDIA自带的一个命令可以详细的展示显卡的运行状态. gpustat gpustat是github上开源的一个小工具,对于v ...

  10. (Set, Map, Collections工具类)JAVA集合框架二

    Java集合框架部分细节总结二 Set 实现类:HashSet,TreeSet HashSet 基于HashCode计算元素存放位置,当计算得出哈希码相同时,会调用equals判断是否相同,相同则拒绝 ...