<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Python connection on a hive 3 server in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/385238#M245661</link>
    <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/105625"&gt;@ZainK&lt;/a&gt;&amp;nbsp;&lt;SPAN&gt;This can happen due to various reasons such as resource constraints, or errors in the code. Do check those aspects.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Mar 2024 09:59:49 GMT</pubDate>
    <dc:creator>smruti</dc:creator>
    <dc:date>2024-03-20T09:59:49Z</dc:date>
    <item>
      <title>Python connection on a hive 3 server</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/383571#M244961</link>
      <description>&lt;P&gt;Hello guys,&lt;/P&gt;&lt;P&gt;I currently work on a company that does provide hive 3.1 servers by using knox or zookeeper (kerberos) authentication methods. I am able to connect and query data by using a odbc connection on my personal computer.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Now I need to set the connection on a virtual jupiter notebook server with pyodbc , so, I am not able to install the ODBC (and probably the server is based on Linux anyway).&lt;/P&gt;&lt;P&gt;I´ve seen many options as pyhive, implya and others, but everything I find is regarding Hive 2 servers.&lt;/P&gt;&lt;P&gt;So, what could I use to set the python connection to the Hive 3 servers?&lt;/P&gt;</description>
      <pubDate>Sat, 17 Feb 2024 05:16:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/383571#M244961</guid>
      <dc:creator>frbelotto</dc:creator>
      <dc:date>2024-02-17T05:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: Python connection on a hive 3 server</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/383575#M244964</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/109230"&gt;@frbelotto&lt;/a&gt;&amp;nbsp;I have not tried with pyhive, I think it requires additional modules if you want to connect using zookeeper quorum. But you could use jaydebeapi python module to connect to Hive3. It works for any type of connection string knox/ZK.&amp;nbsp; You would require Hive driver that you could download from &lt;A href="https://www.cloudera.com/downloads/connectors/hive/jdbc/2-6-23.html" target="_blank" rel="noopener"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;An example on how to to make use of jaydebeapi module to connect to Hive:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;import jaydebeapi

# Connection parameters
jdbc_url = 'jdbc:hive2://knox.host:8443/default'  # JDBC URL for HiveServer2
username = 'your-username'
password = 'your-password'
jar_file = '/path/to/hive-jdbc-driver.jar'  # Path to the Hive JDBC driver JAR file

# Establish connection to Hive
conn = jaydebeapi.connect(
    'org.apache.hive.jdbc.HiveDriver',
    jdbc_url,
    [username, password],
    jar_file
)

# Create cursor
cursor = conn.cursor()

# Execute Hive query
cursor.execute('SELECT * FROM hive_table')

# Fetch results
result = cursor.fetchall()

# Close cursor and connection
cursor.close()
conn.close()&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 18 Feb 2024 17:59:13 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/383575#M244964</guid>
      <dc:creator>smruti</dc:creator>
      <dc:date>2024-02-18T17:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: Python connection on a hive 3 server</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/383794#M245069</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/109230"&gt;@frbelotto&lt;/a&gt;,&amp;nbsp;Did the response assist in resolving your query? If it did, kindly mark the relevant reply as the solution, as it will aid others in locating the answer more easily in the future.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2024 06:54:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/383794#M245069</guid>
      <dc:creator>VidyaSargur</dc:creator>
      <dc:date>2024-02-23T06:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: Python connection on a hive 3 server</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/383814#M245082</link>
      <description>&lt;P&gt;Sorry, I couldn't get it working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using a company owned Jupiter notebook.&lt;/P&gt;&lt;P&gt;The first issue is that it's not finding the org.apache.hive.jdbc.HiveDriver.&lt;/P&gt;&lt;P&gt;I even tried to upload an driver version&amp;nbsp;to my Jupiter space and set it as path but still does not find.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My second question, that I couldn't even test, is how to set it to use kerberos as authentication.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2024 12:15:08 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/383814#M245082</guid>
      <dc:creator>frbelotto</dc:creator>
      <dc:date>2024-02-23T12:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: Python connection on a hive 3 server</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/383843#M245100</link>
      <description>&lt;P&gt;My bad. If you are using the Cloudera JDBC jar, the driver class should be&amp;nbsp;&lt;STRONG&gt;com.cloudera.hive.jdbc.HS2Driver.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;As we are talking about Kerberos authentication, you should get a kerberos ticket in the client machine first, and use jdbc_url as follows:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;jar_file = '/path/to/hive-jdbc.jar'
jdbc_url = 'jdbc:hive2://{server}:{port}/default;principal={principal}'

# Connect to Hive
conn = jaydebeapi.connect('com.cloudera.hive.jdbc.HS2Driver', jdbc_url, ['', ''], jar_file)
cursor = conn.cursor()&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 25 Feb 2024 01:31:37 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/383843#M245100</guid>
      <dc:creator>smruti</dc:creator>
      <dc:date>2024-02-25T01:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Python connection on a hive 3 server</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/383845#M245102</link>
      <description>&lt;P&gt;I will try. An extra question. I don't have admin privileges on the machine, só. Could I just upload the jar driver file to my ipython instance or I need to "install" it on someway ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2024 01:56:09 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/383845#M245102</guid>
      <dc:creator>frbelotto</dc:creator>
      <dc:date>2024-02-26T01:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: Python connection on a hive 3 server</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/383883#M245117</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/109230"&gt;@frbelotto&lt;/a&gt;&amp;nbsp;It does not require any installation. You just need to share the path to the Driver jar file.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2024 13:21:59 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/383883#M245117</guid>
      <dc:creator>smruti</dc:creator>
      <dc:date>2024-02-26T13:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: Python connection on a hive 3 server</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/385119#M245624</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/82698"&gt;@smruti&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Thanks for your contirubution.&lt;/P&gt;&lt;P&gt;I followed your instructions for configuring a Hive connection in Python via JupyterHub. Unfortunately, I encountered the following error:&lt;/P&gt;&lt;P&gt;ERROR - The kernel appears to have died. It will restart automatically.&lt;/P&gt;&lt;P&gt;Have you encountered this error before?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Farman&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 10:31:21 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/385119#M245624</guid>
      <dc:creator>ZainK</dc:creator>
      <dc:date>2024-03-18T10:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: Python connection on a hive 3 server</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/385238#M245661</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/105625"&gt;@ZainK&lt;/a&gt;&amp;nbsp;&lt;SPAN&gt;This can happen due to various reasons such as resource constraints, or errors in the code. Do check those aspects.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Mar 2024 09:59:49 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/385238#M245661</guid>
      <dc:creator>smruti</dc:creator>
      <dc:date>2024-03-20T09:59:49Z</dc:date>
    </item>
    <item>
      <title>Re: Python connection on a hive 3 server</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/385371#M245695</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/109230"&gt;@frbelotto&lt;/a&gt;&amp;nbsp;, a sample code to test connectivity from Python to Hive.&amp;nbsp;&lt;/P&gt;&lt;DIV class="code panel"&gt;&lt;DIV class="codeContent panelContent"&gt;&lt;PRE&gt;from pyhive &lt;SPAN class="code-keyword"&gt;import&lt;/SPAN&gt; hive
&lt;SPAN class="code-keyword"&gt;import&lt;/SPAN&gt; logging
&lt;SPAN class="code-keyword"&gt;import&lt;/SPAN&gt; os

logging.basicConfig(level=logging.DEBUG)
conn = hive.Connection(host=&lt;SPAN class="code-quote"&gt;"hs_host"&lt;/SPAN&gt;,port=10000,database=&lt;SPAN class="code-quote"&gt;'&lt;SPAN class="code-keyword"&gt;default&lt;/SPAN&gt;'&lt;/SPAN&gt;)

cursor = conn.cursor()
cursor.execute(&lt;SPAN class="code-quote"&gt;"show databases"&lt;/SPAN&gt;)
res = cursor.fetchall()
print (res)


#connect = hive.Connection(host=db_host, port=db_port, username=db_user, password=db_password, database=db_name,auth=&lt;SPAN class="code-quote"&gt;'KERBEROS'&lt;/SPAN&gt;,kerberos_service_name=&lt;SPAN class="code-quote"&gt;'hive'&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;make sure to install the below dependencies before running the code:&lt;/P&gt;&lt;DIV class="code panel"&gt;&lt;DIV class="codeContent panelContent"&gt;&lt;PRE&gt;pip3.8 install pyhive
pip3.8 install thrift
pip3.8 install thrift_sasl&lt;/PRE&gt;&lt;P&gt;I hope this helps! Cheers!&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 22 Mar 2024 08:20:31 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/385371#M245695</guid>
      <dc:creator>tj2007</dc:creator>
      <dc:date>2024-03-22T08:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: Python connection on a hive 3 server</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/385810#M245843</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/109230"&gt;@frbelotto&lt;/a&gt;,&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/105625"&gt;@ZainK&lt;/a&gt;&amp;nbsp;Did the response assist in resolving your query? If it did, kindly mark the relevant reply as the solution, as it will aid others in locating the answer more easily in the future.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2024 09:36:22 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Python-connection-on-a-hive-3-server/m-p/385810#M245843</guid>
      <dc:creator>VidyaSargur</dc:creator>
      <dc:date>2024-04-01T09:36:22Z</dc:date>
    </item>
  </channel>
</rss>

