File: rdf_has_bdb.R

package info (click to toggle)
r-cran-rdflib 0.2.5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 596 kB
  • sloc: xml: 66; sh: 13; makefile: 2
file content (42 lines) | stat: -rw-r--r-- 1,291 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#' Check for BDB support
#' 
#' Detect whether Berkeley Database for disk-based storage of RDF graphs
#' is available.  Disk-based storage requires redland package
#' to be installed from source with support for the Berkeley DB 
#' (libdb-dev on Ubuntu, berkeley-db on homebrew), otherwise `rdf()` will
#' fall back to in-memory storage with a warning.
#' 
#' @return TRUE if BDB support is detected, false otherwise
#' @export
#' @examples 
#' rdf_has_bdb()
rdf_has_bdb <- function(){
 rdf_storage("BDB", new_db = TRUE, check_only = TRUE)
}

rdf_has_virtuoso <- function(user="dba", 
                             password="dba", 
                             dsn="Local Virtuoso"){
#  has_driver <- rdf_storage("virtuoso", 
#                            user = user, 
#                            password = password, 
#                            dsn = dsn, 
#                            check_only=TRUE)
  r <- tryCatch(rdf("virtuoso", user = user, 
           password = password, dsn = dsn, fallback = FALSE),
           error = function(e) FALSE)
  if(is.logical(r)){
    has_connection <- r
  } else {
    rdf_add(r, "", "dc:name", "bob")
    if(length(r) >= 1){
      has_connection <- TRUE
    } else { 
      has_connection <- FALSE
    }
    rdf_free(r)
  }

  has_connection
  
}