简体   繁体   English

Hive 和 Hdinsight 与 Azure 上的 python 的连接

[英]Connectivity of Hive and Hdinsight with python on Azure

I want to connect the hive with hdinsight cluster with python script, but due to access issue not able to access cluster dashboard which will give me JDBC url information which helps in making the connection with hive. I want to connect the hive with hdinsight cluster with python script, but due to access issue not able to access cluster dashboard which will give me JDBC url information which helps in making the connection with hive.

Can anyone please help/recommend me the ways to connect hive with hdinsight cluster with help of python.谁能帮助/推荐我在 python 的帮助下将 hive 与 hdinsight 集群连接的方法。

import jaydebeapi
conn = jaydebeapi.connect("org.apache.hive.jdbc.HiveDriver",
       "jdbc:hive2://16.4.5.492:451/default/;ssl=true;transportMode=http;httpPath=/hive2", 
       ['Username', 'Password'],
       ["/jdbc/hive-jdbc-1.2.1-standalone.jar",
        "/jdbc/httpclient-4.4.jar",
        "/jdbc/httpcore-4.4.4.jar"])

WebHCat is a REST API for HCatalog, a table, and storage management layer for Apache Hadoop. WebHCat 是 REST API 用于 HCatalog、表和存储管理层 Apache ZCD64EB3DCFBB45D083A14FZ WebHCat is enabled by default on HDInsight clusters , and is used by various tools to submit jobs, get job status, etc. without logging in to the cluster. WebHCat 在 HDInsight 集群上默认启用,并且被各种工具用于在不登录集群的情况下提交作业、获取作业状态等。 So in a nutshell you can use WebHCat to run the Hive QL in Python.所以简而言之,您可以使用 WebHCat 在 Python 中运行 Hive QL。

Additional reference:附加参考:

https://cwiki.apache.org/confluence/display/Hive/WebHCat https://social.msdn.microsoft.com/Forums/en-US/b8026143-975f-46c9-b937-99f604e3b757/connect-to-hive-in-hdinsight-using-python-app-on-remote-linuxbased-server?forum=hdinsight https://cwiki.apache.org/confluence/display/Hive/WebHCat https://social.msdn.microsoft.com/Forums/en-US/b8026143-975f-46c9-b937-99f604e3b757/connect-to-hive -in-hdinsight-using-python-app-on-remote-linuxbased-server?forum=hdinsight

Additionally you can refer below documentation for making it work with JDBC driver:此外,您可以参考以下文档以使其与 JDBC 驱动程序一起使用:

https://github.com/uglide/azure-content/blob/master/articles/hdinsight/hdinsight-connect-hive-jdbc-driver.md https://github.com/uglide/azure-content/blob/master/articles/hdinsight/hdinsight-connect-hive-jdbc-driver.md

I haven't tried this but once the configuration is completed, you should be able to use below code for querying.我还没有尝试过,但是一旦配置完成,您应该可以使用下面的代码进行查询。

import jaydebeapi
conn = jaydebeapi.connect("org.apache.hive.jdbc.HiveDriver",
       "jdbc:hive2://my_ip_or_url:443/;ssl=true;transportMode=http;httpPath=/hive2", 
       [username, password],
       "/jdbc/hive-jdbc-1.2.1.jar")

Hope it helps.希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM