Skip to content

Commit

Permalink
Create Setup and Database Connection.R
Browse files Browse the repository at this point in the history
  • Loading branch information
LisaLi525 authored Dec 13, 2023
0 parents commit ac06041
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Setup and Database Connection.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Clear all variables and set chunk options
setup_environment <- function() {
rm(list = ls())
knitr::opts_chunk$set(echo = TRUE)
}

# Create a connection to the database
connect_to_database <- function(host, port, user, password, dbname) {
library(RPostgreSQL)
library(dplyr)
library(dbplyr)

db_connection <- src_postgres(dbname, host = host, port = port, user = user, password = password)
return(db_connection)
}

0 comments on commit ac06041

Please sign in to comment.