rsqliteVTable | R Documentation |
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.
rsqliteVTable(db, data, name = substitute(data), ..., .args = list(...),
.createTable = TRUE)
db |
the SQLite database connection, created with |
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 |
This defines an SQL module specific to this data frame and then creates the virtual table within the database.
0 for success.
The purpose of this is to facilitate experimentation to explore indexing of data frames within SQL.
Duncan Temple Lang
https://www.sqlite.org/vtab.html
The RSQLite package.
data(mtcars)
library(RSQLite)
db = dbConnect(SQLite(), ":memory:")
rsqliteVTable(db, mtcars)
dbListTables(db)
dbReadTable(db, "mtcars")
dbGetQuery(db, "SELECT * FROM mtcars WHERE gear > 3")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.