Skip to content
Prev 1375 / 1559 Next

data type mapping for RMySQL

Just for the record, this also happens in Postgresql, so the problem is 
more general. (I tried testing in SQLite but my standalone client seems 
to be encrypting the db and RSQLite cannot use it.) I'm not sure there 
is a solution to this as I do not immediately see how to represent 
bigint in R.

Generic SQL example:

 >mysql test
 >psql  test
 >sqlite test

[ DROP TABLE tester; ]

CREATE TABLE  tester (
       id bigint NOT NULL,
       address bigint NOT NULL
     ) ;

INSERT INTO tester VALUES (1, 2029716610205351937);

SELECT * FROM tester ;

gives
   1 | 2029716610205351937
in mysql, psql, and sqlite

( exit; /q or .quit )
(later DROP TABLE tester;)


 >R

require("RMySQL")
hubdb <- dbConnect("MySQL", dbname="test" )
print(fetch(dbSendQuery(hubdb, "select * from tester;"), n=-1), digits=20)

RMySQL gives
   id             address
1  1 2029716610205351936


require("RPostgreSQL")
hubdb <- dbConnect("PostgreSQL", dbname="test" )
print(fetch(dbSendQuery(hubdb, "select * from tester;"), n=-1), digits=20)
RPostgreSQL gives
   id             address
1  1 2029716610205351936


Paul
On 13-12-20 08:07 AM, Tim Coote wrote: