Re: Converter for decimal.Decimal (again)
Manlio Perillo <[email protected]>
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
Antonio Valente ha scritto: > 2007/3/15, Manlio Perillo <[email protected]>: >> Manlio Perillo ha scritto: > > Thank you! > Do not forget that for SQLite the type affinity of your type is always NUMERIC. This means that, internally, your value will be converted to a float. Try to insert in the table the value of decimal.Decimal('12.323E479') or just decimal.Decimal('12.12345678901234567890') Here what you need (if you do not want to lose precision) is to force the column to have the affinity NONE. Again, you should not use functions like SUM in a query, since SQLite try to force every value to a float (and Nan and Inf are valid floats!). As I can see, the only solution is to prepend to the type name the string 'BLOG. If the affinity of your column is NUMERIC, you can store an invalid float (as an example adding a 'd' after the number). In this case the column affinity will be TEXT. If you really need to store Decimals values, and do some operations with them in the database, just do *not* use SQLite. Regards Manlio Perillo