tpilz / lumpR

Landscape Unit Mapping Program for R
GNU General Public License v3.0
11 stars 12 forks source link

parameter database: sometimes error occurs when closing sqlite database #18

Open tpilz opened 9 years ago

tpilz commented 9 years ago

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.