Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(dplyr)
- library(DBI)
- library(RPostgres)
- library(tibble)
- conn <- dbConnect(RPostgres::Postgres(),
- host = url$host,
- port = url$port,
- dbname = url$dbname,
- user = url$user,
- password = url$password
- )
- test <- tibble(
- words = c("hallo","ja", "nein"),
- value = c(3,4,5),
- time= as.POSIXct(c("2016-05-04 04:32","2016-06-02 09:37","2016-07-12 10:43")))
- test2 <- tibble(
- words = c("hallo","ja", "nein"),
- value = c(3,4,5),
- time= c("2016-05-04 04:32","2016-06-02 09:37","2016-07-12 10:43"))
- dbWriteTable(conn = conn, name = "words", value = test)
- > Error in eval(substitute(expr), envir, enclos) :
- > ERROR: invalid input syntax for type real: "2016-05-04 04:32:00"
- > CONTEXT: COPY words, line 1, column time: "2016-05-04 04:32:00"
- dbWriteTable(conn = conn, name = "words2", value = test2)
- > [1] TRUE
- library(dplyr)
- library(DBI)
- library(RPostgreSQL)
- library(tibble)
- #connect to db
- url <- list(user="postgres",password="postgres",dbname="test")
- conn <- dbConnect(drv="PostgreSQL", user=url$user, password=url$password, dbname = url$dbname)
- test <- tibble(
- words = c("hallo","ja", "nein"),
- value = c(3,4,5),
- time= as.POSIXct(c("2016-05-04 04:32","2016-06-02 09:37","2016-07-12 10:43")))
- test2 <- tibble(
- words = c("hallo","ja", "nein"),
- value = c(3,4,5),
- time= c("2016-05-04 04:32","2016-06-02 09:37","2016-07-12 010:43"))
- dbWriteTable(conn = conn, name = "words", value = test)
- dbWriteTable(conn = conn, name = "words2", value = test2)
- dbDisconnect(conn)
Add Comment
Please, Sign In to add comment