execute query into a given database

Description

Once you have a sqliter database properly set you can execute queries into that database and get your data transformed. By default this function returns a data.frame object, but if you transform your data you can get whatever you need.

Usage

1
2
3
4
5
  execute(object, ...)

  ## S3 method for class 'sqliter'
 execute(object, database, query,
    post_proc = identity, ...)

Arguments

object

sqliter object

database

the SQLite database filename without extension

query

the query string

post_proc

a function to transform data, it receives a database and returns whatever you need.

...

additional arguments used by prepared queries

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
DBM <- sqliter(path=c("data", "another/project/data"))
ds <- execute(DBM, "dummydatabase", "select count(*) from dummytable")
ds <- execute(DBM, "dummydatabase", "select * from dummytable where
      name = :name", name=c("Macunamima", "Borba Gato"))
ds <- execute(DBM, "dummydatabase", "select * from dummytable where
      name = :name", name=c("Macunamima", "Borba Gato"),
        post_proc=function(ds) {
ds <- transform(ds, birthday=as.Date(birthday))
ds
})

## End(Not run)