I'm querying a table that contains a money field with 4 decimal places. but when I fetch the data, they become to Decimal data type with 2 decimal places;
In [4]: b.execute("select lfiyat from tbstokfiyati where lfiyat=0.0428")
In [5]: b.fetchall()
Out[5]: [(Decimal("0.04"),)]
How can I get the correct value?
Thanks,
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'm querying a table that contains a money field with 4 decimal places. but when I fetch the data, they become to Decimal data type with 2 decimal places;
In [4]: b.execute("select lfiyat from tbstokfiyati where lfiyat=0.0428")
In [5]: b.fetchall()
Out[5]: [(Decimal("0.04"),)]
How can I get the correct value?
Thanks,
Tried with lower level adapter with converting money field to varchar but that doesn't worked too;
In [11]: mssql=_mssql.connect(...)
In [13]: mssql.query("select cast(lfiyat as varchar(30)) from tbstokfiyati where lfiyat=0.0428")
Out[13]: 1
In [14]: mssql.fetch_array()
Out[14]: [((('', 1),), 1, [('0.04',)])]
Is this problem could be related with the db server?
Thanks
Ok, I found the problem was not realted with pymssql and I solved it with different CAST command;
select ... CAST(lfiyat AS decimal(10,4)) from ...
But I still don't know why I need to do this to get the real value.