[R] Compress string memCompress/Decompress

Erik Wright eswright at wisc.edu
Mon Jul 12 18:17:59 CEST 2010


Hi Seth,

Can you recreate the example below using dbWriteTable?

Thanks!,
Erik


On Jul 11, 2010, at 6:13 PM, Seth Falcon wrote:

> On Sun, Jul 11, 2010 at 11:31 AM, Matt Shotwell <shotwelm at musc.edu> wrote:
>> On Fri, 2010-07-09 at 20:02 -0400, Erik Wright wrote:
>>> Hi Matt,
>>> 
>>> This works great, thanks!
>>> 
>>> At first I got an error message saying BLOB is not implemented in RSQLite.  When I updated to the latest version it worked.
>> 
>> SQLite began to support BLOBs from version 3.0.
> 
> And RSQLite began supporting BLOBs only just recently :-)
> See the NEWS file for details.
> 
> Below is a minimal example of how you might use BLOBs:
> 
>    db <- dbConnect(SQLite(), dbname = ":memory:")
>    dbGetQuery(db, "CREATE TABLE t1 (name TEXT, data BLOB)")
> 
>    z <- paste("hello", 1:10)
>    df <- data.frame(a = letters[1:10],
>                     z = I(lapply(z, charToRaw)))
>    dbGetPreparedQuery(db, "insert into t1 values (:a, :z)", df)
>    a <- dbGetQuery(db, "select name from t1")
>    checkEquals(10, nrow(a))
>    a <- dbGetQuery(db, "select data from t1")
>    checkEquals(10, nrow(a))
>    a <- dbGetQuery(db, "select * from t1")
>    checkEquals(10, nrow(a))
>    checkEquals(2, ncol(a))
> 
>    checkEquals(z, sapply(a$data, rawToChar))
>    dbDisconnect(db)
> 
> 
> -- 
> Seth Falcon | @sfalcon | http://userprimary.net/



More information about the R-help mailing list