Skip to content

Instantly share code, notes, and snippets.

@krlmlr
Created October 20, 2023 05:37
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 krlmlr/425321377c35aab2e0bec16fe7b6a85f to your computer and use it in GitHub Desktop.
Save krlmlr/425321377c35aab2e0bec16fe7b6a85f to your computer and use it in GitHub Desktop.
Running multiple statements with DBI
library(DBI)
con <- dbConnect(
RPostgres::Postgres(),
...
)
dbExecute(
con,
"CREATE TEMP TABLE x (a int); CREATE TEMP TABLE y (b int)",
immediate = TRUE
)
#> [1] 0
dbGetQuery(con, "SELECT COUNT(*) FROM y")
#> count
#> 1 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment