# NOT RUN {
# For running the examples on systems without PostgreSQL connection:
run <- postgresHasDefault()
library(DBI)
if (run) con <- dbConnect(RPostgres::Postgres())
if (run) dbListTables(con)
if (run) dbWriteTable(con, "mtcars", mtcars, temporary = TRUE)
if (run) dbReadTable(con, "mtcars")
if (run) dbListTables(con)
if (run) dbExistsTable(con, "mtcars")
# A zero row data frame just creates a table definition.
if (run) dbWriteTable(con, "mtcars2", mtcars[0, ], temporary = TRUE)
if (run) dbReadTable(con, "mtcars2")
if (run) dbDisconnect(con)
# }
Run the code above in your browser using DataCamp Workspace