python 链接hive

1,配置hive:启动hiveserver2

在 bin/conf 下面touch 一个hive-site,xml:

添加



          


    hive.server2.thrift.port
    10000
    Port number of HiveServer2 Thrift interface when hive.server2.transport.mode is 'binary'.
 

 
    hive.server2.thrift.bind.host
    127.0.0.1
    Bind host on which to run the HiveServer2 Thrift service.
 

 
    hive.server2.enable.doAs
    false
   
      Setting this property to true will have HiveServer2 execute
      Hive operations as the user making the calls to it.
    如果为True:Hive Server会以提交用户的身份去执行语句
    如果为False:会以hive server daemon的admin user来执行语句

后台启动:

1

nohup hive --service hiveserver2 &

 或者直接:

1

nohup hiveserver2 &

 

 

python :

下载:

pip install sasl
pip install thrift
pip install thrift-sasl

pip install PyHive

 

hive.Connection(host=host, port=port, database=database)#没有设置用户密码

 

你可能感兴趣的:(python 链接hive)