Created
February 16, 2018 18:54
-
-
Save sharlagelfand/acd31a1f3e28eb1a1bbbdb841d79cd26 to your computer and use it in GitHub Desktop.
Inserting data into redshift from R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(glue) | |
library(RPostgreSQL) | |
library(DBI) | |
drv <- dbDriver("PostgreSQL") | |
con <- dbConnect(drv, | |
host=Sys.getenv("JDBCURL"), | |
port = Sys.getenv("PORT"), | |
dbname = Sys.getenv("DBNAME"), | |
user = Sys.getenv("USER"), | |
password = Sys.getenv("PW")) | |
users_syntax <- "123, 1234, 12345" | |
query <- glue(" | |
INSERT INTO table_name (user_id) | |
VALUES ({users})", | |
users = users_syntax) | |
%>% as.character | |
dbSendQuery(con, query) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment