pyhive
from pyhive import hive
import pandas as pd
import numpy as np
class myhive():
def __init__(self,host,port,auth,username,password,database):
self.host=host
self.port=port
self.auth=auth
self.username=username
self.password=password
self.database=database
def Connect(self):
self.conn=hive.connect(host=self.host,port=self.port,auth=self.auth,username=self.username,password=self.password,database=self.database)
#查询数据库表中的所有数据
def Query(self,query_sen):
self.cursor = self.conn.cursor()
self.excute = self.cursor.execute(query_sen)
res = self.cursor.fetchall()
cols=[col[0] for col in cursor.description]
data=pd.DataFrame(np.array(res),columns=cols)
return data
query_sen="select id,pieces_no_id from dp_ods.o_pl_crm_intopieces_dk_s where etl_date='2019-09-05' limit 10"
pyhive=myhive(host=" ",port=10,auth=" ",username=" ",password=" ",database=" ")
hive_connect=pyhive.Connect()
hive_data=pyhive.Query(query_sen)
print(hive_data.head())
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连接hive(失败)
一.安装pyhive pip install sasl(需要来下载至本地安装:https://download.lfd.uci.edu/pythonlibs/q4hpdf1k/sasl-0.2.1-c ...
- pyhive的基本使用
安装 yum -y install cyrus-sasl cyrus-sasl-devel cyrus-sasl-lib # 解决报错:sasl/sasl.h: No such file or di ...
- 初识python 之 离线搭建pyhive环境(含python3安装)
系统版本: centos6.5 python版本:python3.6.8 相关包存放目录:software 注意:以下操作需要用到root权限 安装python3 root操作 cd /lzh/sof ...
随机推荐
- Mac ssh key生成
转载https://blog.csdn.net/wangjunling888/article/details/51115659 1. 查看秘钥是否存在 打开终端查看是否已经存在SSH密钥:cd ~/. ...
- leetcode 437 Path Sum III 路径和
相关问题:112 path sum /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNo ...
- [LeetCode] 272. Closest Binary Search Tree Value II 最近的二叉搜索树的值 II
Given a non-empty binary search tree and a target value, find k values in the BST that are closest t ...
- 【Spring】---【IOC】
Spring 2017-08-15 08:25:57 [IOC] 分享几篇好文 谈谈对Spring IOC的理解 Spring的IOC原理(转载) java框架篇---spring IOC 实现原理 ...
- 精读《Monorepo 的优势》
1. 引言 本周精读的文章是 The many Benefits of Using a Monorepo. 现在介绍 Monorepo 的文章很多,可以分为如下几类:直接介绍 Lerna API 的: ...
- 多线程16-SpinWait
); isCompleted = )); isCompleted = ); isCompleted = true; ...
- [DS+Algo] 010 二叉树的遍历
二叉树遍历 深度优先 一般用递归 一些名词 遍历方式 英文 先序 Preorder 中序 Inorder 后序 Postorder 广度优先 一般用队列 Python 代码示例 class Node( ...
- [转帖]JVM内存结构 VS Java内存模型 VS Java对象模型
JVM内存结构 VS Java内存模型 VS Java对象模型 https://www.hollischuang.com/archives/2509 Java作为一种面向对象的,跨平台语言,其对象.内 ...
- Java——LinkedList使用Demo
package list; import java.util.Iterator; import java.util.LinkedList; public class LinkedListDemo { ...
- 洛谷P1484 种树&洛谷P3620 [APIO/CTSC 2007]数据备份 题解(堆+贪心)
洛谷P1484 种树&洛谷P3620 [APIO/CTSC 2007]数据备份 题解(堆+贪心) 标签:题解 阅读体验:https://zybuluo.com/Junlier/note/132 ...