db_start <- function() {
- drv <- dbDriver('SQLite')
- if (is.null(drv)) stop("db_start: Could not access driver for SQLite.\n")
- con <- dbConnect(drv, dbname=file.path(cache_root,'cran2deb.db'))
- if (is.null(con)) stop("db_start: Could open connection to file 'cran2deb.db' in directory",cache_root,".\n")
+ pg.service <- Sys.getenv('CRAN2DEB_PG')
+ if (!is.null(pg.service) &&
+ any(grepl(".",pg.service))) {
+ drv <- dbDriver("PostgreSQL")
+ if (is.null(drv)) {
+ stop("db_start: Could not access driver for postgresql.")
+ }
+ con <- dbConnect(drv,service=pg.service)
+ if (is.null(con)) {
+ stop("db_start: Could open connection to service ",pg.service)
+ }
+ } else {
+ drv <- dbDriver('SQLite')
+ if (is.null(drv)) stop("db_start: Could not access driver for SQLite.\n")
+ con <- dbConnect(drv, dbname=file.path(cache_root,'cran2deb.db'))
+ if (is.null(con)) stop("db_start: Could open connection to file 'cran2deb.db' in directory",cache_root,".\n")
+ }
if (!dbExistsTable(con,'sysreq_override')) {
dbGetQuery(con,paste('CREATE TABLE sysreq_override ('
,' depend_alias TEXT NOT NULL'