FreeTDS 将 MS SQL 货币类型转换为 python 浮点数,而不是十进制数 [英] FreeTDS translating MS SQL money type to python float, not Decimal

查看:65
本文介绍了FreeTDS 将 MS SQL 货币类型转换为 python 浮点数,而不是十进制数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Linux 中从 Python 连接到 MS SQL Server 数据库.我使用 FreeTDS 驱动程序通过 pyodbc 进行连接.当我从 MSSQL 返回一个货币字段时,它以浮点数形式出现,而不是 Python 十进制数.

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.

问题在于 FreeTDS.如果我从 Windows 运行完全相同的 Python 代码(我不需要使用 FreeTDS),pyodbc 返回 Python 十进制.

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.

在 Linux 中运行代码时如何取回 Python Decimal?

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

推荐答案

这是 FreeTDS 中的一个错误.自 2010 年 8 月 4 日起,该错误已在 FreeTDS 的 CVS 负责人中得到修复(感谢 Freddy Ziglio).有关详细信息,请参阅 web2py 留言板上的我的帖子.

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.

这篇关于FreeTDS 将 MS SQL 货币类型转换为 python 浮点数,而不是十进制数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆