[問題] RMySQL in a function不正常

作者: dreler1 (....)   2019-01-09 00:49:44
[問題類型]:
程式諮詢(我想用R 做某件事情,但是我不知道要怎麼用R 寫出來)
[軟體熟悉度]:
開發者(有撰寫R 的套件經驗)
[問題敘述]:
我使用RMySQL 寫了一個迴圈
其中已經用了
all_cons <- dbListConnections(MySQL())
for (con in all_cons)
dbDisconnect(con)
去關閉connection
如果我不做成function跑起來沒問題
我做成function 之後
Error in .local(dbObj, ...) :
internal error in RS_DBI_getConnection: corrupt connection handle
In addition: There were 50 or more warnings (use warnings() to see the first
50)
我嘗試把找出錯誤發生的地點 (ERRORfile)
但是他整個loop其實跑完了
write("finished all data",ERRORfile,append = TRUE)
這條都跑完了
詳情請見
http://0rz.tw/ooC9n
[環境敘述]:
> sessionInfo()
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United
States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] MOVESdata_0.0.0.9000 tidyr_0.8.2 stringi_1.2.4
readr_1.1.1 readxl_1.1.0
[6] RMySQL_0.10.15 DBI_1.0.0 roxygen2_6.1.1
usethis_1.4.0 devtools_2.0.1
loaded via a namespace (and not attached):
[1] Rcpp_1.0.0 pillar_1.3.0 compiler_3.4.3 cellranger_1.1.0
prettyunits_1.0.2 base64enc_0.1-3
[7] remotes_2.0.2 tools_3.4.3 testthat_2.0.1 digest_0.6.18
pkgbuild_1.0.2 pkgload_1.0.2
[13] tibble_1.4.2 memoise_1.1.0 pkgconfig_2.0.2 rlang_0.3.0.1
cli_1.0.1 rstudioapi_0.8
[19] commonmark_1.7 yaml_2.2.0 withr_2.1.2 stringr_1.3.1
xml2_1.2.0 hms_0.4.2
[25] desc_1.2.0 fs_1.2.6 rprojroot_1.3-2 glue_1.3.0
R6_2.3.0 processx_3.2.1
[31] sessioninfo_1.1.1 callr_3.0.0 purrr_0.2.5 magrittr_1.5
backports_1.1.3 ps_1.2.1
[37] assertthat_0.2.0 crayon_1.3.4
謝謝大家

Links booklink

Contact Us: admin [ a t ] ucptt.com