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的更多相关文章

  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连接hive(失败)

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

  8. pyhive的基本使用

    安装 yum -y install cyrus-sasl cyrus-sasl-devel cyrus-sasl-lib  # 解决报错:sasl/sasl.h: No such file or di ...

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

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

随机推荐

  1. 【Win32 API】远程工具调用

    前言 有时候,影城报障需要远程过去重现和处理,如果电脑没有安装远程工具的话,还需要营业员下载和安装,然后将账号密码发送过来,这样一来一回操作繁琐也浪费时间,所以我们可以设想一下这种场景,售票员点击在p ...

  2. httpd启动显示Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName'

    AH00557: httpd: apr_sockaddr_info_get() failed for masterAH00558: httpd: Could not reliably determin ...

  3. 八:flask-重定向示例

    现象:访问地址a,跳转到地址b,在flask中,使用redirect()来进行重定向 永久性重定向:301,多用于旧网址被废弃了,需要跳转到新网址访问 例如请求www.jingdong.com,会自动 ...

  4. python 接口测试时,后端报错no String-argument constructor/factory method

    解决方法: 1.先将字典转化为序列化的数据类型 data = {"pageNo":0,"pageSize":10,"shopId":15,& ...

  5. powered by Fernflower decompiler

    About Fernflower Fernflower is the first actually working analytical decompiler for Java and probabl ...

  6. 【Linux开发】Linux启动脚本设置

    前言linux有自己一套完整的启动 体系,抓住了linux启动 的脉络,linux的启动 过程将不再神秘.阅读之前建议先看一下附图.本文中假设inittab中设置的init tree为:/etc/rc ...

  7. c++ 十进制、十六进制和BCD的相互转换

    #include <stdio.h> #include <string.h> #include <iostream> using namespace std; // ...

  8. 简单的遍历xml

    #include <opencv2\opencv.hpp> #include <opencv2\highgui\highgui.hpp> #include <opencv ...

  9. Hibernate-Criteria学习笔记

    hibernate_jpa注解 目前最新版的hibernate,5.2,底层整合了jpa,用idea的hibernate工具生成实体时,实体包含了注解的配置文件,缺一不可 如,用户类实体,生成之后是这 ...

  10. Linux环境安装mongodb

    介绍 上篇介绍了Linux环境下安装Node.js的步骤,紧接着来安装mongodb.另外,推荐我的另一篇 Windows下图文详解Mongodb安装及配置,先在Windows下熟悉下mongodb, ...