首先需要安装包:
pip install pyhive[hive]
如果安装报错的话执行:
sudo apt-get install libsasl2-dev
再安装下。
然后需要启动hive服务:
hive --service hiveserver2
修改hive验证方式: 在hive-site.xml中:
<property>
<name>hive.server2.authentication</name>
<value>NOSASL</value>
<description>
Expects one of [nosasl, none, ldap, kerberos, pam, custom].
Client authentication types.
NONE: no authentication check
LDAP: LDAP/AD based authentication
KERBEROS: Kerberos/GSSAPI authentication
CUSTOM: Custom authentication provider
(Use with property hive.server2.custom.authentication.class)
PAM: Pluggable authentication module
NOSASL: Raw transport
</description>
</property>
接下来是python脚本:
from pyhive import hive
cursor = hive.connect(host='myhadoop', auth='NOSASL', database='default').cursor()
cursor.execute('select * from users limit 10')
print(cursor.fetchone())
print(cursor.fetchall())
for i in range(7, 10):
sql = "insert into users VALUEs ({},'username{}')".format(i, str(i))
cursor.execute(sql)
想问一下用户怎么设置头像?我为什么只能是小黄人
我连接以后,代码就卡在hive.Connection这里不动了,这是怎么回事呢
很喜欢这种简约的UI风格
谢谢啦~~
为什么有的高亮 有的不高亮呢
用
Pygments
实现的. 用Pygments
的话写markdown时候需要指定语言才能高亮我就想知道博主代码高亮是怎么实现的?