This function initiates a MySQL connection using stored database credentials through the keyring package. The MySQL tables are added to the connection pane.
get_mysql_connection(keyring_name, service_name)
keyring_name | A character string providing the name of the keyring. |
---|---|
service_name | A character string providing the name of the key. |
A MySQL database connection object.
library(store) library(DBI) library(odbc) # connect to database, using keyring stored credentials con <- get_mysql_connection(keyring_name = "keyring_name", service_name = "database_name")
More information on working with databases using R can be found in RStudio's Databases using R webpages.
# list tables dbListTables(con) # get table database_table <- tbl(con, "table_name") %>% collect() # get query database_query <- dbGetQuery(con, "sql_statement") database_query <- tbl(con, sql("sql_statement")) %>% collect()
dbDisconnect(con)
Other database functions:
get_postgres_connection()
,
get_sqlserver_connection()