-
Notifications
You must be signed in to change notification settings - Fork 0
/
rimport.R
23 lines (20 loc) · 779 Bytes
/
rimport.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Uncomment and run if not already installed.
#install.packages('jsonlite', dependencies=TRUE, repos='http://cran.rstudio.com/')
#install.packages('RPostgreSQL')
#install.packages('RPostgres')
#install.packages('DBI')
#install.packages('dotenv')
library(RPostgreSQL)
library(RPostgres)
library(DBI)
library(dotenv)
#getwd() # to check working directory
setwd("~/Desktop/eit/dansende-fugl") # set to your project path
load_dot_env(file = ".env")
db <- Sys.getenv("POSTGRES_DB")
host_db <- Sys.getenv("HOST")
db_user <- Sys.getenv("DB_USER")
db_password <- Sys.getenv("DB_PASSWORD")
con <- dbConnect(RPostgres::Postgres(), dbname = db, host=host_db, user=db_user, password=db_password)
# SQL query example
unique_comments <- dbGetQuery(con, "SELECT * FROM unique_no_comments")