> On Dec 15, 2018, at 12:49 AM, Frank Millman <fr...@chagford.com> wrote:
> 
> Hi all
> 
> I know that floating point is not precise and not suitable for financial 
> uses. Even so, I am curious about the following -
> 
> SQLite version 3.26.0 2018-12-01 12:34:55
> Enter ".help" for usage hints.
> Connected to a transient in-memory database.
> Use ".open FILENAME" to reopen on a persistent database.
> sqlite> .open /sqlite_db/ccc
> sqlite> select sum(amount_cust) from ar_trans where cust_row_id = 4 and 
> tran_date between '2015-05-01' and '2015-05-31';
> 211496.26
> 
> Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit 
> (AMD64)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import sqlite3
>>>> sqlite3.sqlite_version
> '3.26.0'
>>>> conn = sqlite3.connect('/sqlite_db/ccc')
>>>> cur = conn.cursor()
>>>> cur.execute("select sum(amount_cust) from ar_trans where cust_row_id = 4 
>>>> and tran_date between '2015-05-01' and '2015-05-31'")
> <sqlite3.Cursor object at 0x000002C1D6BBCF80>
>>>> cur.fetchone()
> (211496.25999999992,)
> 
> With the same version of sqlite3 and the same select statement, why does 
> python return a different result from sqlite3.exe?


Because the shell is altering the output to make it easier to read.  Consider:

$ sqlite3
SQLite version 3.16.0 2016-11-04 19:09:39
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> select 211496.25999999992;
211496.26


-j



_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to