在Python/Pyodbc中查询Teradata的问题

wan*_*e99 10 python teradata

我正在尝试使用PyODBC在Python中查询Teradata数据库.与数据库的连接建立得很好; 但是,当我尝试获取结果时,我遇到了这个错误"无效的文字为十进制:你''".请帮忙.

我在RHEL6上,使用Python 2.7.3

这是代码和结果:

import pyodbc

sql = "select * from table"

pyodbc.pooling = False
cnx = pyodbc.connect("DRIVER={Teradata};DBCNAME=host;DATABASE=database;   AUTHENTICATION=LDAP;UID=user;PWD=password", autocommit=True, ANSI=True)
cursor = cnx.cursor()
rows = cursor.execute(sql).fetchone()
Run Code Online (Sandbox Code Playgroud)
InvalidOperation                          Traceback (most recent call last)
<ipython-input-25-f2a0c81ca0e4> in <module>()
----> 1 test.fetchone()

/usr/local/lib/python2.7/decimal.pyc in __new__(cls, value, context)
    546                     context = getcontext()
    547                 return context._raise_error(ConversionSyntax,
--> 548                                 "Invalid literal for Decimal: %r" % value)
    549 
    550             if m.group('sign') == "-":

/usr/local/lib/python2.7/decimal.pyc in _raise_error(self, condition, explanation, *args)
   3864         # Errors should only be risked on copies of the context
   3865         # self._ignored_flags = []
-> 3866         raise error(explanation)
   3867 
   3868     def _ignore_all_flags(self):

InvalidOperation: Invalid literal for Decimal: u''
Run Code Online (Sandbox Code Playgroud)

sho*_*app 0

我发现开箱即用的 pyodbc 可能无法按照http://code.google.com/p/pyodbc/issues/detail?can=1&q=teradata&id=146工作

我验证了该线程中的修复是否有效。查看https://github.com/mkleehammer/pyodbc,向 setup.py 添加额外的命令,重新编译,它似乎可以工作。