How should I handle decimal in SQLalchemy & SQLite

后端 未结 3 1064
慢半拍i
慢半拍i 2020-12-24 07:21

SQLalchemy give me the following warning when I use a Numeric column with an SQLite database engine.

SAWarning: Dialect sqlite+pysqlite does not

3条回答
  •  执笔经年
    2020-12-24 07:44

    Since it looks like you're using decimals for currency values, I'd suggest that you do the safe thing and store the value of currency in its lowest denomination, e.g. 1610 cents instead of 16.10 dollars. Then you can just use an Integer column type.

    It might not be the answer you were expecting, but it solves your problem and is generally considered sane design.

提交回复
热议问题