diff --git a/DESCRIPTION b/DESCRIPTION index 307f206..12b86c9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: rdflib Title: Tools to Manipulate and Query Semantic Data -Version: 0.2.0 +Version: 0.2.1 Authors@R: c(person("Carl", "Boettiger", email = "cboettig@gmail.com", role = c("aut", "cre", "cph"), diff --git a/NEWS.md b/NEWS.md index d46499d..d7b1993 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# rdflib 0.2.1 + +* Minor patch to make test compatible with breaking change in readr 1.2.0 (#30) + # rdflib 0.2.0 ## New Features diff --git a/cran-comments.md b/cran-comments.md index 8af995f..8af506c 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,8 +1,6 @@ Dear CRAN maintainers, -This release adds support for additional backend databases (Postgres, MySQL, -Virtuoso, and SQLite), along with appropriate documentation. See NEWS for -details. +This release patches a unit test that was broken by the recent readr 1.2.0 release. ## Test environments diff --git a/inst/examples/virtuoso-direct.R b/inst/examples/virtuoso-direct.R new file mode 100644 index 0000000..d0bf933 --- /dev/null +++ b/inst/examples/virtuoso-direct.R @@ -0,0 +1,91 @@ +library(DBI) +library(odbc) + +virtuoso <- dbConnect(odbc::odbc(), + driver = "Virtuoso", + uid = "dba", + pwd = "dba", + host = "virtuoso", + port = "1111") + +## It's alive! +virtuoso + +## Bulk import -- fast! +dbGetQuery(virtuoso, "ld_dir('/var/data/', '*.nq', 'rdflib')" ) +dbGetQuery(virtuoso, "rdf_loader_run()" ) + + +## List all graphs -- look, we have one called 'rdflib' now! +dbGetQuery(virtuoso, + "SPARQL SELECT DISTINCT ?g WHERE { GRAPH ?g {?s ?p ?o} } ORDER BY ?g" +) + + +## Select FROM GRAPH +dbGetQuery(virtuoso, "SPARQL SELECT * FROM WHERE { {?s ?p ?o} } LIMIT 10") + +dbGetQuery(virtuoso, "SPARQL SELECT * FROM WHERE { {?s ?o} } LIMIT 10") + +## Wow, we can write standard tables into Virtuoso too... +#dbWriteTable(virtuoso, "iris", iris) # Dots not allowed in column names +dbWriteTable(virtuoso, "mtcars", mtcars) +dbListTables(virtuoso, table_name = "mt%") +dbReadTable(virtuoso, "mtcars") + + +## Clear graph +dbGetQuery(virtuoso, "SPARQL CLEAR GRAPH ") + + +## Counting triples in each different graph... +q <- "SPARQL SELECT ?g ?s ?p ?o WHERE { GRAPH ?g {?s ?p ?o} }" +df <- dbGetQuery(virtuoso, q) +library(dplyr) +df %>% count(g) + + + +#remotes::install_github("ropensci/rdflib") +library(rdflib) +library(nycflights13) +library(dplyr) +## prefix foreign keys +uri_flights <- flights %>% + mutate(tailnum = paste0("planes:", tailnum), + carrier = paste0("airlines:", carrier)) + +h <- here::here("data/rdflib/inst/extdata") +write_nquads(airlines, file.path(h, "airlines.nq"), key = "carrier", prefix = "airlines:") +write_nquads(planes, file.path(h, "planes.nq"), key = "tailnum", prefix = "planes:") +write_nquads(uri_flights, file.path(h, "uri_flights.nq"), prefix = "flights:") + +## Bulk import -- fast! +dbGetQuery(virtuoso, "ld_dir('/var/data/', '*.nq', 'rdflib')" ) +dbGetQuery(virtuoso, "rdf_loader_run()" ) + + + + + +remotes::install_github("ropensci/rdflib") +library(rdflib) +triplestore <- rdf(storage = "virtuoso", + user = "dba", + password = "dba", + host = "virtuoso:1111" +) +triplestore +#write_nquads(iris, "iris.nq", prefix = "iris") +#read_nquads("iris.nq", rdf = triplestore) +## Works! +triplestore + +## We can query with rdflib too! +query <- "SELECT ?s ?p ?o WHERE {?s ?p ?o } LIMIT 10" +out <- rdf_query(triplestore, query) +rdf_free(triplestore) + + + +