tanrj / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

cursor.description type_code inconsistency #42

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Environment:
 * SQL Server 2008
 * pyodbc version 2.1.3 (python 2.6)

What steps will reproduce the problem?
1. create a databse table with 2 columns:
  * col1    decimal(24,12)
  * col2    float(24)
2. insert one row with values (5.1, 5.1)
3. using pyodbc, run sql "SELECT * FROM TEST_TABLE", and get
cursor.description, which contains:
('col1', <type 'float'>, None, 24, None, None, True)
('col2', <type 'float'>, None, 24, None, None, True)
4. the data retrieved is:
(Decimal('5.100000000000'), 5.0999999046325684)

I expect the type for 'col1' to be decimal, not float.
So data is of correct type, but the cursor.description provides incorrect
information.

Or is there a way to get information about the python type that will be used?

Original issue reported on code.google.com by ivan.mel...@gmail.com on 1 Apr 2009 at 3:51

GoogleCodeExporter commented 8 years ago
Cursor.description is the way to get the information you want.  That's a bug...

Original comment by mkleehammer on 2 Apr 2009 at 4:39

GoogleCodeExporter commented 8 years ago
Any idea when you could find time to fix it? I would like to automatically 
generate
UI based on type information, and this issue messes things up.
Thanks

Original comment by ivan.mel...@gmail.com on 17 Apr 2009 at 5:46

GoogleCodeExporter commented 8 years ago
Sorry for the delay -- its been a hectic year.  How about this weekend?

Original comment by mkleehammer on 17 Apr 2009 at 11:25

GoogleCodeExporter commented 8 years ago
Would be much appreciated, Thanks.

Original comment by ivan.mel...@gmail.com on 18 Apr 2009 at 5:07

GoogleCodeExporter commented 8 years ago
Fixed in 5b611be267c924d71493666f512d4c4161f8c30f, which will be in 2.1.5, to be
released today.

Updated the SQL Server test_small_decimal unit test to catch this.

Original comment by mkleehammer on 19 Apr 2009 at 9:36

GoogleCodeExporter commented 8 years ago

Original comment by mkleehammer on 21 Nov 2010 at 4:45