How do people handle Decimal data with SA / SQLite? Newer versions of SA give the following warning:
SAWarning: Dialect sqlite+pysqlite does *not* support Decimal objects natively, and SQLAlchemy must convert from floating point - rounding errors and other issues may occur. Please consider storing Decimal numbers as strings or integers on this platform for lossless storage. I assume that the gist of the message is similar to the reason that decimal.Decimal objects in Python can't be initialized with a float, just int's and string's. I'm working on an accounting application where I would like to use Decimal fields to store monetary amounts. If I understand the warning, I should convert the Python Decimal data and from ints to store in the database. I think I can safely get away with ints if I design things so that every data is stored with the same number of decimal digits. I could also use strings in the database, but that would eliminate the ability to do math operations, such as SUM in the SQL code. Also, is there an single place in the code to to the int / Decimal conversion. Ideally, I would like the application to take advantage of Decimal database objects in databases where they are supported, so it would be nice to have one place in the code that changes depending on which database is in use. Thanks, Mark -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
