有没有办法强制断开一个类似的src_tbls对象?dplyrRPostgreSQL::dbDisconnect
参见例如:
> src_temp <- src_postgres(dbname = "temp", host = "127.0.0.1", port = 5432, user = "x", password = "y")
Error in postgresqlNewConnection(drv, ...) :
RS-DBI driver: (cannot allocate a new connection -- maximum of 16 connections already opened)
Run Code Online (Sandbox Code Playgroud)
作为旁注,几秒后它会很快自动断开:
Auto-disconnecting postgres connection (3734, 26)
Run Code Online (Sandbox Code Playgroud)
之后您可以src_postgres再次运行该命令.
hrb*_*str 10
你可以做:
RPostgreSQL::dbDisconnect(src_temp$con)
Run Code Online (Sandbox Code Playgroud)
迫使断开连接.
这就是dplyr(通过dbi-s3.r源文件)从此函数调用垃圾回收的原因:
# Creates an environment that disconnects the database when it's
# garbage collected
db_disconnector <- function(con, name, quiet = FALSE) {
reg.finalizer(environment(), function(...) {
if (!quiet) {
message("Auto-disconnecting ", name, " connection ",
"(", paste(con@Id, collapse = ", "), ")")
}
dbDisconnect(con)
})
environment()
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3344 次 |
| 最近记录: |