Python Connection to Hive

杀马特。学长 韩版系。学妹 提交于 2019-12-04 19:51:12

问题


I installed the Hortonworks Hive ODBC driver and created a connection in the Data sources. I tested it and it worked successfully.

I installed PyODBC and wrote the following code

import os, sys, pyodbc;
con = pyodbc.connect("DSN=MyCon")

I got error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pyodbc.Error: ('HYC00', '[HYC00] [Hortonworks][ODBC] (11470) Transactions are not supported. (11470) (SQLSetConnnectAttr(SQL_ATTR_AUTOCOMMIT))')

I also tried

import pyodbc, sys, os
pyodbc.pooling = False
pyodbc.autocommit = False
con = pyodbc.connect("DSN=MyCon")

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pyodbc.Error: ('HYC00', '[HYC00] [Hortonworks][ODBC] (11470) Transactions are not supported. (11470) (SQLSetConnnectAttr(SQL_ATTR_AUTOCOMMIT))')

also tried

con = pyodbc.connect("DSN=Tenet", autocommit=False)


Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pyodbc.Error: ('HYC00', '[HYC00] [Hortonworks][ODBC] (11470) Transactions are not supported. (11470) (SQLSetConnnectAttr(SQL_ATTR_AUTOCOMMIT))')

回答1:


I solved it..... I am not deleting my question and putting the answer here

pyodbc.autocommit = True
con = pyodbc.connect("DSN=MyCon", autocommit=True)

This was done based on advice of this read

https://code.google.com/p/pyodbc/issues/detail?id=162

** thanks to the advice from Kyle Porter below... it totally makes sense now **



来源:https://stackoverflow.com/questions/29664537/python-connection-to-hive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!