Machine: RHEL 5.3 x86_64 / Python 2.7.3 / pyodbc-3.0.3
Database: IBM Netezza TwinFin Appliance
ODBC: NZ odbc client for Linux
Instance
create table tst(a double, b numeric(9,4), c varchar(10), d char(4));
insert into tst select 1.01, 1.01, 'aa', 'aa';
select * from tst;
A | B | C | D
------+--------+----+------
1.01 | 1.0100 | aa | aa
TEST
import pyodbc
conn = pyodbc.connect("DSN=vntest")
cursor = conn.cursor()
Test 1
cursor.execute("select a,c,d from tst")
for row in cursor:
print row
OUTPUT: (1.01, 'aa', 'aa ')
Test 2
cursor.execute("select b from tst")
for row in cursor:
print row
OUTPUT:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Python-2.7.3/lib/python2.7/decimal.py", line 548, in __new__
"Invalid literal for Decimal: %r" % value)
File "/usr/local/Python-2.7.3/lib/python2.7/decimal.py", line 3866, in _raise_error
raise error(explanation)
decimal.InvalidOperation: Invalid literal for Decimal: u''
I would appreciate any help with this. Thanks.