Is there any way I can create a .sqlite file using a local R data frame?
Asked
Active
Viewed 109 times
0
-
1Yes, this is possible. Just use your favorite internet search engine and serach for R sqlite. Then you will find: rsqlite.r-dbi.org that shows you an example. More examples ca be found in StackOverflow, e.g. [this one](https://stackoverflow.com/questions/4332976/how-to-import-csv-into-sqlite-using-rsqlite). – tpetzoldt May 17 '21 at 06:30
1 Answers
1
Like this?
library(DBI)
con = dbConnect(RSQLite::SQLite(),dbname = 'test.db')
dbWriteTable(conn = con, name = "Tbl_test", value = mtcars)
dbListTables(conn = con)
#> [1] "Tbl_test"
dbDisconnect(con)
dir(".")
#>[1] "test.db"

Waldi
- 39,242
- 6
- 30
- 78
-
Hi @Waldi: a question to the experienced SO user: what is the recommended way to answer such basic questions: with a code example or just by links to available resources? – tpetzoldt May 17 '21 at 06:27
-
@tpezoldt, difficult to tell, however link to available ressources should stay in comments, and code example is an answer. – Waldi May 17 '21 at 06:32