genomewalker
4/12/2017 - 6:35 AM

Write tables to DB with R

Write tables to DB with R

library(RPostgreSQL)  # loads the PostgreSQL driver  
drv <- dbDriver("PostgreSQL")  # creates a connection to the postgres database  # note that "con" will be used later in each connection to the database  
con <- dbConnect(drv, dbname = "osd_analysis", host = "localhost", port = 5432)  
dbWriteTable(con, c("osd_analysis", "bgc_graph_c1_metadata"), value=dt,overwrite=TRUE,row.names=FALSE)