- Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathSQLtoJSON_R.R
More file actions
Latest commit
17 lines (13 loc) · 384 Bytes
/
Copy pathSQLtoJSON_R.R
File metadata and controls
17 lines (13 loc) · 384 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
library(RSQLite)
library(jsonlite)
# IMPORT SQL DATA
conn<- dbConnect(RSQLite::SQLite(), dbname="CLData.db")
cldata<- dbGetQuery(conn, "SELECT * FROM cldata")
dbDisconnect(conn)
# CONVERT TO JSON
jdata<- toJSON(cldata, pretty=TRUE)
# EXPORT JSON
fileConn<- file("CLData_R.json")
writeLines(jdata, fileConn)
close(fileConn)
cat("Successfully migrated SQL data to JSON!\n")