[R] pass vector binding to DBI parameter (rsqlite)

Dan Muresan danmbox at gmail.com
Tue Aug 12 17:55:35 CEST 2014


Hi, is there a way to bind vectors to DBI query parameters? The
following tells me that vectors are sent as separate values:

> library("RSQLite")
> c <- dbConnect (SQLite())
> dbGetQuery(c, "create table tst (x int, y int)")
> dbGetQuery(c, "insert into tst values (?, ?)", data.frame(x=c (1,2,1,2), y=c(3, 4, 5, 6)))
> dbReadTable(c, "tst")
  x y
1 1 3
2 2 4
3 1 5
4 2 6
> dbGetQuery(c, "select * from tst where y not in (?)", c(7,6))
  x y
1 1 3
2 2 4
3 1 5
4 2 6
5 1 3
6 2 4
7 1 5

This looks like 2 result sets (4 + 3 entries), not one.

Is there to send multiple values to a '?' binding? Is this at all
possible using the R DBI interface (not necessarily with rsqlite)?



More information about the R-help mailing list