FreeTDS translating MS SQL money type to python fl

2019-08-17 15:21发布

问题:

I am connecting to an MS SQL Server db from Python in Linux. I am connecting via pyodbc using the FreeTDS driver. When I return a money field from MSSQL it comes through as a float, rather than a Python Decimal.

The problem is with FreeTDS. If I run the exact same Python code from Windows (where I do not need to use FreeTDS), pyodbc returns a Python Decimal.

How can I get back a Python Decimal when I'm running the code in Linux?

回答1:

You could always just convert it to Decimal when it comes back...



回答2:

It was a bug in FreeTDS. The bug has been fixed in the CVS head of FreeTDS as of August 4, 2010 (thanks Freddy Ziglio). See my post on the web2py message board for more info.