python 链接操作

启动远程链接

hive --service hiveserver2 --hiveconf hive.root.logger=DEBUG,console

lsof -i:10000 查看是否启动成功

报错修改文件 /software/hadoop/hadoop-2.7.7/etc/hadoop/core-site.xml

<property>
	<name>hadoop.proxyuser.root.hosts</name>
	<value>*</value>
</property>
<property>
	<name>hadoop.proxyuser.root.groups</name>
	<value>*</value>
</property>

链接

beeline -u jdbc:hive2//127.0.0.1:10000 -n root


beeline


!connect jdbc:hive2://192.168.0.197:10000


!connect jdbc:hive2://master:10000

链接报错解决方案(TProtocolException: TProtocolException(type=4))

原因是由于connect方法里面没有增加参数:auth_mechanism='PLAIN'

报错 AttributeError: ‘TSocket’ object has no attribute ‘isOpen’

pip uninstall thrift-sasl
pip install thrift-sasl==0.2.1

报错 thriftpy.transport.TTransportException: TTransportException(type=1, message=“Could not start SASL: b’Error in sasl_client_start (-4) SASL(-4): no mechanism available: Unable to find a callback: 2’”)

pip uninstall SASL

报错 TypeError: can’t concat str to bytes

init.py 第94行

header = struct.pack(">BI", status, len(body))
#按照网上的提供的办法增加对BODY的处理
if (type(body) is str):
  body = body.encode()
self._trans.write(header + body)
self._trans.flush()

解决完毕启动成功python操作数据库


create database myhive;

create table if not exists userLogo(id int,username string,password string, age int);

insert into userLogo values(1,'xiaodou','B',28);

select * from userLogo;


--  删除库 
drop database if exists db_name; 

--  强制删除库 
drop database if exists db_name cascade; 

--  删除表 
drop table if exists employee; 

--  清空表 
truncate table employee; 

--  清空表,第二种方式 
insert overwrite table employee select * from employee where 1=0; 

--  删除分区 
alter table employee_table drop partition (stat_year_month>='2018-01'); 

--  按条件删除数据 
insert overwrite table employee_table select * from employee_table where id>'180203a15f';

安装库

pip install ipython six bit_array thriftpy thrift_sasl==0.2.1 sasl impyla

from impala.dbapi import connect

conn = connect(host="192.168.0.197", port=10000, user="root", password="admin",database="databig", auth_mechanism="PLAIN")

cur = conn.cursor()

cur.execute("show databases")

print(cur.fetchall())

conn.close()


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值