參考 https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-PythonClient
https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2#SettingUpHiveServer2-PythonClientDriver
Example:
1. Connect using simple authentication to HiveServer2 on localhost:10000
$ beeline -u jdbc:hive2://localhost:10000 username password
2. Connect using simple authentication to HiveServer2 on hs.local:10000 using -n for username and -p for password
$ beeline -n username -p password -u jdbc:hive2://hs2.local:10012
3. Connect using Kerberos authentication with hive/localhost@mydomain.com as HiveServer2 principal (現在一般生產集群都是用Kerberos 認證)
$ beeline -u "jdbc:hive2://hs2.local:10013/default;principal=hive/localhost@mydomain.com
4. Connect using SSL connection to HiveServer2 on localhost at 10000
$ beeline jdbc:hive2://localhost:10000/default;ssl=true;sslTrustStore=/usr/local/truststore;trustStorePassword=mytruststorepassword
5. Connect using LDAP authentication
$ beeline -u jdbc:hive2://hs2.local:10013/default <ldap-username> <ldap-password>
后面就像sql一樣使用

python client:
https://github.com/cloudera/impyla(實測python3.7裝不上)
https://github.com/dropbox/PyHive
能裝上,但是對kerberos不是很友好
這個鏈接是pyhive針對kerberos認證討論的操作方法
- Install kerberos on your own computer
- Setup kerberos on your computer so that it connects to the remote kerberos server (/etc/krb5.conf)
- Given a keytab file (provided by your kerberos administrator), you can authenticate your computer to the remote kerberos server using
kinit -kt your.keytab username@YOUR_KERBEROS_REALM - You can check that you have a valid kerberos ticket using
klist - You can now launch pyhive with kerberos.
