tpilz/lumpR

parameter database: sometimes error occurs when closing sqlite database

tpilz opened this issue · 0 comments

tpilz commented

Function odbcClose() from package RODBC which is used internally within db_* functions sometimes causes an error when using sqlite 3 (reprocuded under opensuse using unixODBC and Windows):

library(RODBC)
# connect to ODBC sqlite database
con <- odbcConnect(dbname, believeNRows=F)
# fetch data from database table
dat <- sqlFetch(con, table)
# close database
odbcClose(con)

Fehler in odbcGetErrMsg(channel) : 
  erstes Argument ist kein offener RODBC-Kanal
Zusätzlich: Warnmeldungen:
1: In odbcClose(con) : [RODBC] Fehler in SQLDisconnect
2: In odbcClose(con) : [RODBC] Fehler in SQLFreeconnect

However, channel is still open as this works:

library(RODBC)
con <- odbcConnect(dbname, believeNRows=F)
dat <- sqlFetch(con, table)
dat2 <- sqlFetch(con, other_table)

And this causes no trouble:

library(RODBC)
con <- odbcConnect(dbname, believeNRows=F)
odbcClose(con)

Using another DBMS works without errors as well.