This function initiates a SQL Server connection using windows authentication, either using stored database credentials through the keyring package or else requesting database credentials in the console. The SQL Server tables are added to the connection pane.
get_sqlserver_connection(keyring_name, service_name, keyring = TRUE)
keyring_name | A character string providing the name of the keyring. |
---|---|
service_name | A character string providing the name of the key. |
keyring | default TRUE uses the keyring, FALSE requests credentials. |
A SQL Server database connection object.
library(store) library(DBI) library(odbc) # connect to database, using keyring stored credentials con <- get_sqlserver_connection(keyring_name = "keyring_name", service_name = "database_name", keyring = TRUE)
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_mysql_connection()
,
get_postgres_connection()