Skip to content

Commit

Permalink
0.2.1 patch release
Browse files Browse the repository at this point in the history
  • Loading branch information
cboettig committed Nov 25, 2018
1 parent f8638f7 commit 20676b8
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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"),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
91 changes: 91 additions & 0 deletions inst/examples/virtuoso-direct.R
Original file line number Diff line number Diff line change
@@ -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 <rdflib> WHERE { {?s ?p ?o} } LIMIT 10")

dbGetQuery(virtuoso, "SPARQL SELECT * FROM <rdflib> WHERE { {?s <flights:dep_delay> ?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 <rdflib>
dbGetQuery(virtuoso, "SPARQL CLEAR GRAPH <rdflib>")


## 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)




0 comments on commit 20676b8

Please sign in to comment.