Re: Problem with sqlite3 and Decimal

2015-12-12 Thread Frank Millman
"Chris Angelico" wrote in message news:CAPTjJmrfw-qNx-a=3q2qj244fgvxz3mpe4wa-wdusmchxuf...@mail.gmail.com... On Sun, Dec 13, 2015 at 4:00 PM, Frank Millman wrote: > My new solution is to pass a 'scale' factor into my aggregate function. > The > function uses the Decimal quantize method to ro

Re: Problem with sqlite3 and Decimal

2015-12-12 Thread Chris Angelico
On Sun, Dec 13, 2015 at 4:00 PM, Frank Millman wrote: > My new solution is to pass a 'scale' factor into my aggregate function. The > function uses the Decimal quantize method to round the result before > returning. So far it seems to be working. So, effectively, you're using fixed point arithmet

Re: Problem with sqlite3 and Decimal

2015-12-12 Thread Frank Millman
"Frank Millman" wrote in message news:n4gigr$f51$1...@ger.gmane.org... I have found a workaround for my problem, but first I needed to understand what was going on more clearly. This is what I have figured out. [...] The reason for the '#' in the above function is that sqlite3 passes the cu

Re: Problem with sqlite3 and Decimal

2015-12-11 Thread Chris Angelico
IOn Sat, Dec 12, 2015 at 6:31 PM, Frank Millman wrote: > I have found a workaround for my problem, but first I needed to understand > what was going on more clearly. This is what I have figured out. > > 1. The solution in the SO article is a bit of sleight of hand, though very > effective. It does

Re: Problem with sqlite3 and Decimal

2015-12-11 Thread Frank Millman
"Frank Millman" wrote in message news:n4ei3l$b98$1...@ger.gmane.org... I need to store Decimal objects in a sqlite3 database, using Python 3.4 on Windows 7. I followed the instructions here - http://stackoverflow.com/questions/6319409/how-to-convert-python-decimal-to-sqlite-numeric It seem

Re: Problem with sqlite3 and Decimal

2015-12-11 Thread Frank Millman
"Chris Angelico" wrote in message news:CAPTjJmoPXFSnXe1QA8MjjncBZBpqNkztha8YHJv=mbm--ze...@mail.gmail.com... On Sat, Dec 12, 2015 at 4:10 PM, Frank Millman wrote: > I can reproduce your example above. However, if I set the initial value > to > 5678.7, then the sequence goes > > 5678.7 > 580

Re: Problem with sqlite3 and Decimal

2015-12-11 Thread Chris Angelico
On Sat, Dec 12, 2015 at 4:10 PM, Frank Millman wrote: > I can reproduce your example above. However, if I set the initial value to > 5678.7, then the sequence goes > > 5678.7 > 5802.15 > 5925.6 > 6049.05 > 6172.5 > > I would have thought that adding 123.45 to 5802.15 would always produce the > sam

Re: Problem with sqlite3 and Decimal (fwd)

2015-12-11 Thread Frank Millman
"Igor Korot" wrote in message news:CA+FnnTyZY_1=62rbk_kkz39tkeoa6jvmfn9qs17as-2yd4d...@mail.gmail.com... Yes, I saw your post to sqlite3 ML. And I do know that by default sqlite3 does not have many types supported. However, all you need to do is save it as DECIMAL(10,2). It is supported is sql

Re: Problem with sqlite3 and Decimal

2015-12-11 Thread Frank Millman
"Chris Angelico" wrote in message news:captjjmor6newucco7xtsswyyfbgwcwz8jt-mjjkysjocfu7...@mail.gmail.com... On Fri, Dec 11, 2015 at 8:21 PM, Frank Millman 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

Re: Problem with sqlite3 and Decimal

2015-12-11 Thread Chris Angelico
On Fri, Dec 11, 2015 at 8:21 PM, Frank Millman 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> upd

Re: Problem with sqlite3 and Decimal (fwd)

2015-12-11 Thread Igor Korot
Hi, Frank, On Fri, Dec 11, 2015 at 9:27 AM, Frank Millman wrote: > "Igor Korot" wrote in message > news:CA+FnnTyaLLEsYGU7v2BreySDOQ1rVsMzJ=5f4iQTLW3=tn=e...@mail.gmail.com... > >> Hi, >> >> > To: python-list@python.org >> > From: "Frank Mi

Re: Problem with sqlite3 and Decimal (fwd)

2015-12-11 Thread Frank Millman
"Igor Korot" wrote in message news:CA+FnnTyaLLEsYGU7v2BreySDOQ1rVsMzJ=5f4iQTLW3=tn=e...@mail.gmail.com... Hi, > To: python-list@python.org > From: "Frank Millman" > Subject: Problem with sqlite3 and Decimal > Date: Fri, 11 Dec 2015 11:21:53 +0200 > Lines

Re: Problem with sqlite3 and Decimal (fwd)

2015-12-11 Thread Igor Korot
Hi, On Fri, Dec 11, 2015 at 8:45 AM, Laura Creighton wrote: > From python-list. > Very weird. > Another reason not to use sqlite3 > > --- Forwarded Message > > To: python-list@python.org > From: "Frank Millman" > Subject: Problem with sqlite3 and Deci

Problem with sqlite3 and Decimal (fwd)

2015-12-11 Thread Laura Creighton
>From python-list. Very weird. Another reason not to use sqlite3 --- Forwarded Message To: python-list@python.org From: "Frank Millman" 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 sql

Problem with sqlite3 and Decimal

2015-12-11 Thread Frank Millman
Hi all I need to store Decimal objects in a sqlite3 database, using Python 3.4 on Windows 7. I followed the instructions here - http://stackoverflow.com/questions/6319409/how-to-convert-python-decimal-to-sqlite-numeric It seemed to work well, but then I hit a problem. Here is a stripped-do