title: How to retrieve large numbers from database with RSQLite? (Buffer overflow?)
body: <p>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.</p>
  
  <p>Is there a way to retrieve very large integers/floating point values via RSQLite without this issue?</p>
  
  <p>Here is a minimal example:</p>
  
  <pre><code>library("DBI"); library("RSQLite")
  db.h &lt;- 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)
  </code></pre>
  
  <p>The output I get is as follows:</p>
  
  <pre><code>&gt;        a           b
  &gt; 1 value1   282817178
  &gt; 2 value2 -1559175274
  </code></pre>
  
  <p>I'm using RStudio 0.98.501 (R version 3.0.2) on 32-bit Windows 7, if that's relevant at all.</p>
  
  <p>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.</p>