Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion DECIMAL columns: Cursor.description is <type 'float'>?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
alexander.landg...@gmx.net  
View profile  
 More options Mar 30 2009, 10:00 am
From: alexander.landg...@gmx.net
Date: Mon, 30 Mar 2009 07:00:06 -0700 (PDT)
Local: Mon, Mar 30 2009 10:00 am
Subject: DECIMAL columns: Cursor.description is <type 'float'>?
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]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.