query: execute query into a given database

Description Usage Arguments Examples

View source: R/sqliter.R

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
query(object, ...)

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

Arguments

object

sqliter object

...

additional arguments used by prepared queries

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.

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 <- query(DBM, "dummydatabase", "select count(*) from dummytable")
ds <- query(DBM, "dummydatabase", "select * from dummytable where
      name = :name", name=c("Macunamima", "Borba Gato"))
ds <- query(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)

wilsonfreitas/sqliter documentation built on May 4, 2019, 6:28 a.m.