Problem with sqlite3 and Decimal (fwd)

Frank Millman frank at chagford.com
Fri Dec 11 09:27:27 EST 2015


"Igor Korot"  wrote in message 
news:CA+FnnTyaLLEsYGU7v2BreySDOQ1rVsMzJ=5f4iQTLW3=tn=E+Q at mail.gmail.com...

> Hi,
>
> > To: python-list at python.org
> > From: "Frank Millman" <frank at chagford.com>
> > Subject: Problem with sqlite3 and Decimal
> > Date: Fri, 11 Dec 2015 11:21:53 +0200
> > Lines: 71
> >
> > Hi all
> >
> > I need to store Decimal objects in a sqlite3 database, using Python 3.4 
> > on
> > Windows 7.
> >
[...]
>
> >
> > 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.
>
> Is there a reason you are saving it as the string?
> What happens when you save it as decimal?
>

Well, maybe you know something that I don't, but my understanding is that 
sqlite3 has a very limited range of supported data types, and decimal is not 
one of them.

The stackoverflow article explains how to emulate a decimal type, and it 
works well most of the time.

I found that I could reproduce the problem using sqlite3 directly, without 
using Python, so I have sent a post to the sqlite3 mailing list. I will 
report back with any info received.

Frank





More information about the Python-list mailing list