[R] Detect expired RSQLiteConnection?

Duncan Murdoch murdoch.duncan at gmail.com
Wed Sep 3 00:01:15 CEST 2014


On 02/09/2014, 5:28 PM, David Winsemius wrote:
> 
> On Sep 2, 2014, at 5:32 AM, Duncan Murdoch wrote:
> 
>> Is there a test for an expired RSQLiteConnection?  For example, if I run
>>
>> library(RSQLite)
>> f <- tempfile()
>> con <- dbConnect(SQLite(), f)
>> dbDisconnect(con)
>> con
>>
>> then I get
>>
>>> con
>> <Expired SQLiteConnection: DBI CON (11737, 2)>
>>
>> and most operations using it give errors. (In my case I have a
>> persistent connection object, but if I save the workspace and then
>> reload it, I get the expired connection.) I'd like to detect this case.
>> Do I need to use try(), or parse the result of printing it?
>>
> 
> Noodling through the S4 and then the S3 code I found:
> 
> ?isIdCurrent as the test in `sqliteCloseConnection`
>>
> 

Thanks!  (And this makes it look like an implementation of dbIsValid
might be easy.)

Duncan Murdoch



More information about the R-help mailing list