[R-sig-DB] DBI+RSQLite NAMESPACE problem

Herve Pages hp@ge@ @end|ng |rom |hcrc@org
Fri Apr 20 20:22:36 CEST 2007


Hi,

With DBI and RSQlite now having namespaces, if I want to do this in my package:


.onLoad <- function(libname, pkgname)
{
    drv <- dbDriver("SQLite")
    ...
}

then I need to import DBI in my NAMESPACE which is fine.

Now at load time, my package will be able to call DBI::dbDriver() but
DBI::dbDriver() itself will fail because it tries to call the SQLite()
function. SQLite() is defined in the RSQLite package but DBI doesn't
import RSQLite hence the load-time error.

It seems that the workaround is to put RSQLite in the Depends field
of my package. With this addition, it loads :-)

However, 'R CMD check mypackage' will still complain with the following
warning:

  * checking whether the name space can be loaded with stated dependencies ... WARNING
  Error in do.call(as.character(drvName), list(...)) :
          could not find function "SQLite"
  Error: .onLoad failed in 'loadNamespace' for 'mypackage'
  Execution halted

  A namespace must be able to be loaded with just the base namespace loaded:
  otherwise if the namespace gets loaded by a saved object, the session will
  be unable to start.

  Probably some imports need to be declared in the NAMESPACE file.

This error occurs in the DBI::dbDriver() method: 'drvName' contains the "SQLite"
string so do.call() tries to call the SQLite() function which is of course not
defined.

Any idea how this could be addressed?

Thanks,
H.




More information about the R-sig-DB mailing list