Python Connection to Hive



我安装了 Hortonworks Hive ODBC 驱动程序并在数据源中创建了一个连接。我测试了它,它工作成功。

我安装了 PyODBC 并编写了以下代码

import os, sys, pyodbc;
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))')

我也试过

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))')

也尝试过

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))')

我解决了.....我不会删除我的问题并将答案放在这里

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

这是根据此阅读的建议完成的

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

**感谢下面凯尔波特的建议...现在完全有意义**

相关内容

  • 没有找到相关文章

最新更新