| get_postgres_connection | R Documentation |
This function initiates a PostgreSQL connection using stored database credentials through the keyring package.
get_postgres_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 PostgreSQL database connection object.
library(DBI)
library(odbc)
# connect to database, using keyring stored credentials
con <- get_postgres_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_mysql_connection(),
get_sqlserver_connection()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.