Skip to content

Commit

Permalink
move code
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Nov 24, 2016
1 parent 2251a94 commit 72b6cbf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
19 changes: 2 additions & 17 deletions UPDATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Two components are shipped with the package that can be updated:

- SQLite library
- Datasets
- Datasets database

Ideally the update should happen right *after* each CRAN release, so that a new SQLite version is tested for some time before it's released to CRAN.

Expand All @@ -16,22 +16,7 @@ Ideally the update should happen right *after* each CRAN release, so that a new

1. Update `NEWS`

Ideally this should happen right *after* each CRAN release, so that a new SQLite version is tested for some time before it's released to CRAN.

## Datasets database

RSQLite includes one SQLite database (accessible from `datasetsDb()` that contains all data frames in the datasets package. This is the code that created it.

```R
tables <- unique(data(package = "datasets")$results[, 3])
tables <- tables[!grepl("(", tables, fixed = TRUE)]

con <- dbConnect(SQLite(), "inst/db/datasets.sqlite")
for(table in tables) {
df <- getExportedValue("datasets", table)
if (!is.data.frame(df)) next

message("Creating table: ", table)
dbWriteTable(con, table, as.data.frame(df), overwrite = TRUE)
}
```
RSQLite includes one SQLite database (accessible from `datasetsDb()` that contains all data frames in the datasets package. The code that created it is located in `data-raw/datasets.R`.
11 changes: 11 additions & 0 deletions data-raw/datasets.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tables <- unique(data(package = "datasets")$results[, 3])
tables <- tables[!grepl("(", tables, fixed = TRUE)]

con <- dbConnect(SQLite(), "inst/db/datasets.sqlite")
for(table in tables) {
df <- getExportedValue("datasets", table)
if (!is.data.frame(df)) next

message("Creating table: ", table)
dbWriteTable(con, table, as.data.frame(df), overwrite = TRUE)
}

0 comments on commit 72b6cbf

Please sign in to comment.