i_l*_*ate 8 database r teradata dplyr dbplyr
背景:
我使用dbplyr和dplyr从数据库中提取数据,然后我使用该命令dbSendQuery()来构建我的表。
问题:
建立表后,如果我运行另一个命令,我会收到以下警告:
Warning messages:
1. In new_result(connection@ptr, statement): Cancelling previous query
2. In connection_release(conn@ptr) :? There is a result object still in use.
The connection will be automatically released when it is closed.
题:
因为我没有要获取的结果(我正在发送构建表的命令),所以我不确定如何避免此警告。目前,我在构建表后断开连接,错误消失了。我能做些什么来避免这个警告?
目前一切正常,我只有这个警告。我只是想避免它,因为我认为我应该在建立我的桌子后清理一些东西。
代码示例
# establish connection
con = DBI::dbConnect(<connection stuff here>)
# connect to table and database
transactions = tbl(con,in_schema(“DATABASE_NAME”,”TABLE_NAME”))
# build query string
query_string = “SELECT * FROM some_table”
# drop current version of table
DBI::dbSendQuery(con,paste('DROP TABLE MY_DB.MY_TABLE'))
# build new version of table
DBI::dbSendQuery(con,paste('CREATE TABLE PABLE MY_DB.MY_TABLE AS (‘,query_string,’) WITH DATA'))
ssa*_*ols 10
即使您没有使用 SELECT 子句检索内容,DBI 仍会在每次调用DBI::dbSendQuery(). DBI::dbClearResult()在DBI::dbSendQuery()通话之间尝试一下。
DBI::dbClearResult() 做:
Clear A Result Set
Frees all resources (local and remote) associated with a
result set. In some cases (e.g., very large result sets) this
can be a critical step to avoid exhausting resources
(memory, file descriptors, etc.)
Run Code Online (Sandbox Code Playgroud)
手册页的示例应该给出应该如何调用该函数的提示:
Clear A Result Set
Frees all resources (local and remote) associated with a
result set. In some cases (e.g., very large result sets) this
can be a critical step to avoid exhausting resources
(memory, file descriptors, etc.)
Run Code Online (Sandbox Code Playgroud)