rsqliteVTable: Create an SQLite virutal table directly from an R Data Frame

rsqliteVTableR Documentation

Create an SQLite virutal table directly from an R Data Frame

Description

This function treats a data frame in R as a virtual table in an SQLite database. This table can then be used in SQL queries, including connecting its rows to other tables in the database.

Usage

rsqliteVTable(db, data, name = substitute(data), ..., .args = list(...),
              .createTable = TRUE)

Arguments

db

the SQLite database connection, created with dbConnect.

data

the R data frame containing the data to use for the SQL table.

name

the name to use for the SQL table

...

additional arguments to be passed to the newly created virtual table model. These can, in principle, be used to customize its behavior

.args

an alternative way to specify additional arguments, rather than ...

.createTable

logical value. If this is TRUE, we create the virtual table. Otherwise, we just define the module.

Details

This defines an SQL module specific to this data frame and then creates the virtual table within the database.

Value

0 for success.

Note

The purpose of this is to facilitate experimentation to explore indexing of data frames within SQL.

Author(s)

Duncan Temple Lang

References

https://www.sqlite.org/vtab.html

See Also

The RSQLite package.

Examples

data(mtcars)
library(RSQLite)
db = dbConnect(SQLite(), ":memory:")
rsqliteVTable(db, mtcars)
dbListTables(db)
dbReadTable(db, "mtcars")
dbGetQuery(db, "SELECT * FROM mtcars WHERE gear > 3")

duncantl/RSQLiteVirtualTable documentation built on Nov. 23, 2023, 4:23 p.m.