连接hive图形界面和代码

1.sql developer(客户端)

  1. 下载Oracle SQL Developer(http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html
    2.Hive驱动程序
    (1)下载驱动程序
    https://www.cloudera.com/downloads/connectors/hive/jdbc/2-6-1.html
    (2)工具–>首选项
    (3)左侧定位到“数据库”–>“第三方JDBC驱动程序”,右侧窗口单击“添加条目”按钮来添加Hive驱动程序
    tip:1.连接的主机ip是(HiveServer2所在的机子)
    2.用户名和密码在HiveServer2所在的机子里面的hive-site.xml文件里面配:在这里插入图片描述
  2. python连接hive
    一.impyla方式连接
    准备工作

1.安装
1、pip install six
2.pip install sasl
3、pip install thriftpy[hive]
4.pip install thrift_sasl (pip install thrift-sasl==0.2.1)
安装错误。根据提示下载包
链接:https://www.lfd.uci.edu/~gohlke/pythonlibs/ (包含各种包)
5.pip install impyla
测试:

>     from impala.dbapi import connect
>     conn = connect(host='HiveServer2所在的机子ip',port = 10000,auth_mechanism='PLAIN',user='root',password='root',database='myhive')
>     cur=conn.cursor()
>     cur.execute('select * from student')
>     print(cur.fetchall())
>     cur.close()
>     conn.close()

二.PyHive方式连接
准备工作
1.安装
1、pip install six
2.pip install sasl
3、pip install thriftpy[hive]
4.pip install thrift_sasl (pip install thrift_sasl==0.3.0)
安装错误。根据提示下载包
链接:https://www.lfd.uci.edu/~gohlke/pythonlibs/ (包含各种包)
(如果没安装wheel记得先安装wheel:pip install wheel)
5.pip install PyHive
测试:

from pyhive import hive
conn = hive.connect(host='192.168.84.162',port = 10000,username='root')
cur=conn.cursor()
cur.execute('show databases')
print(cur.fetchall())
cur.close()
conn.close()
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值