| db_connect | R Documentation |
Gets a database connection based on the connection name in config.yml.
For most use cases, prefer db_query() or db_execute() which handle
connection lifecycle automatically.
db_connect(name)
name |
Character. Name of the connection in config.yml (e.g., "postgres") |
A database connection object (DBIConnection)
if (FALSE) {
# Preferred: use db_query() which auto-disconnects
users <- db_query("SELECT * FROM users", "postgres")
# Manual connection management (remember to disconnect!)
conn <- db_connect("postgres")
DBI::dbListTables(conn)
DBI::dbDisconnect(conn)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.