sqlalchemy/python查询中的数字字段的SQL Server精度和比例
我在表中有一个SQL Server数字(10,2)字段。示例记录具有DE DATABASE中保存的DE值25.00。 当我在Python脚本中执行SQLalchemy查询时,无论我将字段定义为模型脚本的表类中的float或数字,它总是返回值2500。
SSMS所看到的示例值:
percentualExecucao = db.Column(db.Float)
*** 2500.0< class'float'>
如果我将de line类型更改为:
percentualExecucao = db.Column(db.Numeric)
我有:
*** 2500<类'Decimal.decimal'>
我在这里想念什么?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我能够复制您的问题。用我的Windows“区域”格式设置为“葡萄牙(巴西)”
并使用古代的“ SQL Server” ODBC驱动程序,
如果我将“区域性”更改为“否”,我会得到正确的结果
请注意,这不是Sqlalchemy中的错误。我通过普通PyoDBC获得了相同的结果:
实际上,这似乎是pyodbc
htttps> htttps> https ://github.com/mkleehammer/pyodbc/issues/753
I am able to reproduce your issue. With my Windows "Region" format set to "Portugese (Brazil)"
and using the ancient "SQL Server" ODBC driver, I get
If I change "regional" to "no" then I get the correct result
Note that this is not a bug in SQLAlchemy. I get the same results with plain pyodbc:
In fact, this seems to be a known issue with pyodbc
https://github.com/mkleehammer/pyodbc/issues/753
在@gord Thompson的帮助下,使用
建议解决问题,
With the kind help of @Gord Thompson, the problem was solved using
as suggested in,
https://github.com/mkleehammer/pyodbc/issues/753