vendredi 8 janvier 2016

SQLAlchemy query raises unnecessary warning about sqlite and Decimal, how to specifically disable?

I'm using SQLAlchemy via pyramid accessing a simple sqlite database.

As I was building my progressively more complex queries, I got this 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.

One of my queries does this (paraphrasing):-

session.query(subquery.c.a*100.0/(subquery.c.b+subquery.c.c))

In this case, subquery is the name of a subquery, and a, b, and c are integers.

I'm not saving the result of the query or running any commits, this is purely data extraction/querying, hence I was surprised when the warning above was raised. How do I ignore this warning without filtering it out totally (in case in future I do accidentally save Decimal data to the database)?

Aucun commentaire:

Enregistrer un commentaire