mysql 10分钟内的数据库,在Shiny应用程序中,如果发生任何更改,如何每10分钟从MySQL数据库刷新一次数据...

I've made dashboard using shiny, shinydashboard and RMySQL package.

Following is what I wrote in order to refresh data every 10 minutes if any change occured.

In global.R

con = dbConnect(MySQL(), host, user, pass, db)

check_func

get_func

In server.R

function(input, output, session) {

# check every 10 minutes for any change

data

session$onSessionEnded(function() {dbDisconnect(con)})

However, above code infrequently generates corrupt connection handle error from check_func.

Warning: Error in .local: internal error in RS_DBI_getConnection: corrupt connection handle

Should I put dbConnect code inside server function?

Any better ideas?

解决方案This adds a new level of abstraction when connecting to a database: instead of directly fetching a connection from the database, you will create an object (called a pool) with a reference to that database. The pool holds a number of connections to the database. ... Each time you make a query, you are querying the pool, rather than the database. ... You never have to create or close connections directly: the pool knows when it should grow, shrink or keep steady.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值