alexander...@gmx.net
unread,Mar 30, 2009, 10:00:06 AM3/30/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pyodbc
DECIMAL columns are stored as decimal.Decimal in Row objects.
But their type_code in Cursor.description is <type 'float'>
Is this the expected behaviour?
C:\>type issue_1.py
#!/usr/bin/env python
# -*- coding: ISO-8859-1 -*-
import ConfigParser
import types
import pyodbc
def main(Dsn, Uid, Pwd, Database):
Connection = pyodbc.connect("DSN=%s;UID=%s;PWD=%s;DATABASE=%s" %
(Dsn, Uid, Pwd, Database))
Cursor = Connection.cursor()
Cursor.execute("SELECT CAST(3.5 AS DECIMAL(2,1)) AS x;")
Rows = Cursor.fetchall()
print "type(column in Row) : ", type(Rows[0].x)
print "type_code in Cursor.description: ", Cursor.description[0]
[1]
if __name__ == "__main__":
Config = ConfigParser.ConfigParser()
Config.read("logon.cfg")
main(
Config.get("Teradata", "Dsn")
,Config.get("Teradata", "Uid")
,Config.get("Teradata", "Pwd")
,Config.get("Teradata", "Database")
)
C:\>python issue_1.py
type(column in Row) : <class 'decimal.Decimal'>
type_code in Cursor.description: <type 'float'>
C:\>
[MS Windows Server 2003 SP2 + Python 2.5.1 + pyodbc 2.1.3 + Teradata
12 RDBMS]