I have a database with various token and frequency counts. When I try to retrieve these from within R using RSQLite I get low negative numbers, so presumably there is a buffer overflow issue. If I open the database in say sqliteman and manually query it the data are returned correctly, so it must be to do with DBI or RSQLite.
Is there a way to retrieve very large integers/floating point values via RSQLite without this issue?
Here is a minimal example:
library("DBI"); library("RSQLite")
db.h <- dbConnect(RSQLite::SQLite(), dbname=":memory:")
dbGetQuery(db.h, "CREATE TABLE test (a TEXT, b INT)")
dbGetQuery(db.h, "INSERT INTO test VALUES ('value1', 282817178)")
dbGetQuery(db.h, "INSERT INTO test VALUES ('value2', 15620693910)")
result = dbGetQuery(db.h, "SELECT * FROM test")
result
dbDisconnect(db.h)
The output I get is as follows:
> a b
> 1 value1 282817178
> 2 value2 -1559175274
I'm using RStudio 0.98.501 (R version 3.0.2) on 32-bit Windows 7, if that's relevant at all.
Edit: Note that SQLite 3 uses 64 bit integers for all values in memory and request processing. Using BIGINT in place of INT as suggested in the comments below produces the same overflow issue.
Aucun commentaire:
Enregistrer un commentaire