sql <- "SHOW TABLES; SELECT 1+1 as Two;"
sql2 <- system.file("sql", "mtcars.mysql", package = "etl")
sql3 <- "SELECT * FROM user WHERE user = 'mysql';SELECT * FROM user WHERE 't' = 't';"
if (require(RSQLite)) {
con <- dbConnect(RSQLite::SQLite())
dbRunScript(con, "SELECT 1+1 as Two; VACUUM; ANALYZE;")
}
if (FALSE) {
if (require(RMySQL)) {
con <- dbConnect(RMySQL::MySQL(), default.file = path.expand("~/.my.cnf"),
group = "client", user = NULL, password = NULL, dbname = "mysql", host = "127.0.0.1")
dbRunScript(con, script = sql)
dbRunScript(con, script = sql2)
dbRunScript(con, script = sql3)
dbDisconnect(con)
}
}
Run the code above in your browser using DataLab