Skip to content

Commit 76ee94d

Browse files
committed
Add script to read from SQLite file
1 parent 23cc496 commit 76ee94d

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

inst/extdata/read_sqlite_file.R

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#
2+
# description: This script opens a database connection to a file in SQLite
3+
# format, lists the tables and reads the table contents into a list.
4+
#
5+
# author: Hauke Sonnenberg
6+
# created: 2020-02-18
7+
#
8+
9+
#install.packages("RSQLite")
10+
library(DBI)
11+
12+
# Create an ephemeral in-memory RSQLite database
13+
#con <- dbConnect(RSQLite::SQLite(), "~/Projekte2/dms/pdb.eni")
14+
con <- dbConnect(RSQLite::SQLite(), "~/Projekte2/dms/sdb.eni")
15+
16+
table_names <- dbListTables(con)
17+
18+
contents <- lapply(setNames(nm = table_names), dbReadTable, con = con)
19+
20+
str(contents, 2)
21+
22+
x <- contents$refs[, c("id", "keywords")]
23+
24+
View(x)
25+
26+
#write.csv(x, "keywords.csv", row.names = FALSE)
27+
28+
dbDisconnect(con)

0 commit comments

Comments
 (0)