Created
February 20, 2014 09:06
Revisions
-
____________. created this gist
Feb 20, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ library(RMySQL) library(GetoptLong) # had to work with a secure connection to a MySQL # make a option file, e.g. opts.cnf " [client] user=kenny host=mysqldb ssl-ca=ca.crt ssl-cert=cert.crt ssl-key=mykey.key " # other assignments # e.g. df_name = "extraction_{{country}}" # run query multiple times across different country tables countries = c("singapore", "malaysia", "thailand") for (country in countries) { country_query = qq(query, code.pattern="\\{\\{CODE\\}\\}") country_df_name = qq(df_name, code.pattern="\\{\\{CODE\\}\\}") con = dbConnect(MySQL(), user="kenny", dbname=db, host="mysqldb", default.file="opts.cnf") tmp_df = dbGetQuery(con, country_query) assign(country_df_name, tmp_df) dbDisconnect(con) }