与Hive的Python连接 [英] Python Connection to Hive

查看:347
本文介绍了与Hive的Python连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了Hortonworks Hive ODBC驱动程序,并在数据源中创建了一个连接.我对其进行了测试,并成功运行了.

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

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

I installed PyODBC and wrote the following code

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

推荐答案

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

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

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

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

这篇关于与Hive的Python连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆