Skip to content

Instantly share code, notes, and snippets.

@alitrack
Created August 11, 2016 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alitrack/931e0eb83d06f12e86ea803549086ca0 to your computer and use it in GitHub Desktop.
Save alitrack/931e0eb83d06f12e86ea803549086ca0 to your computer and use it in GitHub Desktop.
PostgreSQL
library(readxl, quietly=TRUE)
df <- read_excel("d:/my.xlsx",col_names = TRUE)
library(RPostgreSQL)
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, user='postgres', password='', dbname='alitrack', host='postgres.alitrack.com')
postgresqlpqExec(con, "SET client_encoding = 'GBK'")
dbWriteTable(con, c("my_schema","my_table"), data.frame(df), row.names = FALSE)
# Free up resources
dbDisconnect(con)
dbUnloadDriver(drv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment