Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #100292 > unrolled thread

Re: Problem with sqlite3 and Decimal

Started byChris Angelico <rosuav@gmail.com>
First post2015-12-12 05:45 +1100
Last post2015-12-12 05:45 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Problem with sqlite3 and Decimal Chris Angelico <rosuav@gmail.com> - 2015-12-12 05:45 +1100

#100292 — Re: Problem with sqlite3 and Decimal

FromChris Angelico <rosuav@gmail.com>
Date2015-12-12 05:45 +1100
SubjectRe: Problem with sqlite3 and Decimal
Message-ID<mailman.154.1449859548.12405.python-list@python.org>
On Fri, Dec 11, 2015 at 8:21 PM, Frank Millman <frank@chagford.com> wrote:
> I noticed one oddity - I am asking sqlite3 to store the value as a string,
> but then I am asking it to perform arithmetic on it.

It's an SQLite3 issue, not a Python one. I used the sqlite3
stand-alone tool to do the same thing:

sqlite> update fmtemp set bal = bal + cast('123.45' as numeric);
sqlite> select bal from fmtemp;
...
5678.7
5802.15
5925.59999999999

And this might be why:

https://www.sqlite.org/datatype3.html

SQLite doesn't *have* all the SQL data types, and NUMERIC is one of
the ones that isn't available. If you recreate your example using
PostgreSQL, it should work fine.

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web