library(RSQLite)
library(DBI)
# hàm tro giup
db <- "chinook.db"
run_query <- function(q){
conn <- dbConnect(SQLite(), db)
result <- dbGetQuery(conn, q)
dbDisconnect(conn)
return(result)
}
# hàm thực thi
show_table <- function(){
q = "SELECT name, type FROM sqlite_master WHERE type IN ('table', 'view')"
return(run_query(q))
}
show_table()
## [1] name type
## <0 rows> (or 0-length row.names)