[sqlite] decimal precision with DOUBLE columns

1 view
Skip to first unread message

Brice Lambi

unread,
Dec 9, 2009, 1:26:24 PM12/9/09
to sqlite...@sqlite.org
Hello,

I have a table with a DOUBLE column but anytime I select from it I only
get two decimal places. When I do a dump it will dump the original
value out at the correct precision. Example:


sqlite> select lat,lon from location limit 10;
44.18|-96.19
44.18|-96.19
44.18|-96.19
44.18|-96.19
...

sqlite> .dump
...
INSERT INTO "location" VALUES(44.04889722,-96.06321667,577.2912);
...

Also when I access this database from python I see the same thing. How
can I tell it to give me the entire number?

Thanks,
Brice Lambi
_______________________________________________
sqlite-users mailing list
sqlite...@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Simon Slavin

unread,
Dec 9, 2009, 2:08:51 PM12/9/09
to General Discussion of SQLite Database

On 9 Dec 2009, at 6:26pm, Brice Lambi wrote:

> I have a table with a DOUBLE column

No you don't. SQLite does not have a DOUBLE type:

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

Define those columns as REAL instead.

> ...
> INSERT INTO "location" VALUES(44.04889722,-96.06321667,577.2912);

You will not be able to get that precision out. In most standard GPS applications this won't matter: SINGLE is more precise than a normal GPS fix. However, if you really want the extra precision you'll have to store your numbers as text.

Simon.

Reply all
Reply to author
Forward
0 new messages