I have a PostgreSQL database on my machine that I routinely connect to through R. I have had no issues reading, writing, or appending data to the database in the past. Recently I upgraded to 4.2.1 and since then any time I try to read data from the database with DBI::dbGetQuery()
or to write data using DBI::dbWriteTable(append = TRUE)
RStudio crashed.
Any help would be appreciated!
Here is the code I am running:
library(tidyverse)
library(DBI)
library(RMySQL)
library(RPostgreSQL)
pg <- dbDriver("PostgreSQL")
db_connection <- dbConnect(pg, dbname = "williampetti",
user = "williampetti",
password = "",
host = "localhost",
port = 5432)
data(mtcars)
# create a table using the mtcars dataset
# there is no issue writing to create a brand new table
DBI::dbWriteTable(db_connection
, name = 'mtcars_test'
, value = mtcars
, overwrite = TRUE)
# view the fields in the new table
# no error here
DBI::dbListFields(db_connection, 'mtcars_test')
# attempt to read data from the table
# this crashes RStudio, but processes fine when using R directly
DBI::dbGetQuery(db_connection
, 'select * from mtcars_test')
# Trying to append the table results in a crash in both RStudio and R directly
DBI::dbWriteTable(db_connection
, name = 'mtcars_test'
, value = mtcars
, append = TRUE)
My session info is below:
PostgresSQL 12
RStudio 2022.07.1 (Build 554)
R version 4.2.1 (2022-06-23)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.2.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
Random number generation:
RNG: Mersenne-Twister
Normal: Inversion
Sample: Rounding
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RPostgreSQL_0.7-3 RMySQL_0.10.23 DBI_1.1.3 forcats_0.5.1 stringr_1.4.0
[6] dplyr_1.0.9 purrr_0.3.4 readr_2.1.2 tidyr_1.2.0 tibble_3.1.8
[11] ggplot2_3.3.6 tidyverse_1.3.2
loaded via a namespace (and not attached):
[1] bitops_1.0-7 fs_1.5.2 usethis_2.1.6 lubridate_1.8.0
[5] devtools_2.4.4 webshot_0.5.3 httr_1.4.3 tools_4.2.1
[9] profvis_0.3.7 backports_1.4.1 utf8_1.2.2 R6_2.5.1
[13] colorspace_2.0-3 urlchecker_1.0.1 withr_2.5.0 tidyselect_1.1.2
[17] prettyunits_1.1.1 processx_3.7.0 curl_4.3.2 compiler_4.2.1
[21] cli_3.3.0 rvest_1.0.2 xml2_1.3.3 triebeard_0.3.0
[25] myDBconnections_0.1.0 scales_1.2.0 callr_3.7.1 systemfonts_1.0.4
[29] commonmark_1.8.0 digest_0.6.29 svglite_2.1.0 rmarkdown_2.14
[33] base64enc_0.1-3 pkgconfig_2.0.3 htmltools_0.5.3 bpettir_0.1.0
[37] sessioninfo_1.2.2 dbplyr_2.2.1 fastmap_1.1.0 htmlwidgets_1.5.4
[41] rlang_1.0.4 readxl_1.4.0 rstudioapi_0.13 shiny_1.7.2
[45] generics_0.1.3 jsonlite_1.8.0 googlesheets4_1.0.0 RCurl_1.98-1.8
[49] magrittr_2.0.3 kableExtra_1.3.4 emayili_0.7.10 Rcpp_1.0.9
[53] munsell_0.5.0 fansi_1.0.3 logger_0.2.2 lifecycle_1.0.1
[57] stringi_1.7.8 pkgbuild_1.3.1 grid_4.2.1 promises_1.2.0.1
[61] crayon_1.5.1 miniUI_0.1.1.1 haven_2.5.0 hms_1.1.1
[65] knitr_1.39 ps_1.7.1 pillar_1.8.0 pkgload_1.3.0
[69] reprex_2.0.1 glue_1.6.2 evaluate_0.15 remotes_2.4.2
[73] BiocManager_1.30.18 modelr_0.1.8 urltools_1.7.3 vctrs_0.4.1
[77] tzdb_0.3.0 httpuv_1.6.5 cellranger_1.1.0 gtable_0.3.0
[81] assertthat_0.2.1 cachem_1.0.6 xfun_0.31 mime_0.12
[85] h2o_3.36.1.2 xtable_1.8-4 broom_1.0.0 later_1.3.0
[89] viridisLite_0.4.0 googledrive_2.0.0 gargle_1.2.0 memoise_2.0.1
[93] ellipsis_0.3.2