Problem with sqlite3 and Decimal (fwd)

Frank Millman frank at chagford.com
Sat Dec 12 00:22:42 EST 2015


"Igor Korot"  wrote in message 
news:CA+FnnTyZY_1=62Rbk_kKZ39tkeoA6JVmFn9qs17aS-2YD4dVnA at mail.gmail.com...
>
> Yes, I saw your post to sqlite3 ML.
> And I do know that by default sqlite3 does not have many types supported.
>
> However, all you need to do is save it as DECIMAL(10,2).
> It is supported is sqlite3 and it will have NUMERIC affinity (ref 1)
> or REAL (ref 2), which means the data will
> be stored as decimals and not a string.
>

Do you mean CREATE TABLE fmtemp (acno INT, balance DECIMAL(10,2));  ?

I tried that, but I got exactly the same result.

The answer, as explained by several people on the sqlite3 ML, is that 
sqlite3 does not have a true decimal type and therefore uses floating point 
internally. As we all know from many questions asked on this forum, floating 
point and exact decimal representation are incompatible.

Frank





More information about the Python-list mailing list