Re: Easy and simple Linux triple-store

Righty-ho Tom,

Super! Trying it out now.

Though imho this info could feature more prominently in the initial README
at https://github.com/ruby-rdf/rdf in the tutorial section in between
"Using RDF.rb and Spira to process RDF data from the British Ordnance
Survey"
and
"Getting started with RDF and SPARQL using 4store and RDF.rb"
?

Specifically the Using code from https://github.com/ruby-rdf/rdf-do:

require 'rdf'
require 'rdf/ntriples'
require 'data_objects'
require 'do_sqlite3'
require 'rdf/do'

repo = RDF::DataObjects::Repository.new uri: 'sqlite3:test.db'
# repo = RDF::DataObjects::Repository.new uri:
'postgres://postgres@server/database'
# heroku_repo = RDF::DataObjects::Repository.new uri: ENV['DATABASE_URL']
repo.load('http://datagraph.org/jhacker/foaf.nt')

# How many statements did we have?
repo.count
#=> 10

# Get the URI of the first subject
jhacker = repo.first.subject
#=> #<RDF::URI(http://datagraph.org/jhacker/foaf)>

# Delete everything to do with it
jhacker_statements = repo.query(subject: jhacker)
repo.delete *jhacker_statements
repo.count
#=> 7

# with Postgres, we could have done this, but SQLite gives us a locking error:
# repo.delete(*repo.query(subject: jhacker))

# Changed our mind--bring it back
repo.insert *jhacker_statements
repo.count
#=> 10

Having said that I'm getting an error on repo.first.subject

…/vendor/cache/ruby/2.3.0/gems/rdf-2.2.11/lib/rdf/model/dataset.rb:67:in
`each_statement': undefined method `each' for nil:NilClass (NoMethodError)
    from
…/vendor/cache/ruby/2.3.0/gems/rdf-2.2.11/lib/rdf/mixin/queryable.rb:172:in
`first'
    from test-store.rb:24:in `<main>'

On 1 November 2017 at 17:19, Tom Johnson <johnson.tom@gmail.com> wrote:

> > I can't find a single simple tutorial about using ruby-rdf to write to,
> modify, and query my own local triple-store.
>
> Ruby RDF has a `Repository`[0] abstraction that allows more-or-less
> transparent read/write over a number of backend implementations.
>
> The default implementation is an in-memory store, but many others exist,
> including for 4store[1], virtuoso[2], blazegraph[3], etc...
>
> Arguably the best maintained of these is `rdf-do`[4], which stores graphs
> to SQL through the DataObjects ORM.
> This gives you the option to just use Sqlite, if you please. This
> approach is not the most performant or scalable, but it's
> probably suitable for a web application, and work to swap to something
> more robust later should be fairly minimal (provided
> you can implement the `RDF::Repository` interface on your chosen backend.
> If you're using Ruby RDF, this is probably the
> solution you are looking for.
>
> [0] http://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Repository
> [1] https://github.com/fumi/rdf-4store
> [2] https://github.com/ruby-rdf/rdf-virtuoso
> [3] https://github.com/ruby-rdf/rdf-blazegraph
> [4] https://github.com/ruby-rdf/rdf-do
>
> On Wed, Nov 1, 2017 at 9:53 AM, Leif Warner <abimelech@gmail.com> wrote:
>
>> I think Redland would be the equivalent of SQLite. I think it's backed by
>> BerkeleyDB or something. The whole suite comes with lots of useful
>> command-line tools.
>>
>> You could also just maintain an in-memory graph, and re-write it to disk
>> on program exit. Can write modifications to disk as they happen for more
>> durability, as a write-ahead log.
>>
>> On Nov 1, 2017 4:32 AM, "Anthony Durity" <a.durity@umail.ucc.ie> wrote:
>>
>>> Hullo all,
>>>
>>> Apologies if this is a stupid question.
>>>
>>> I would like to know if there is any tech that would be the triple-store
>>> equivalent to Sqlite? What I want is to create my only local graph based on
>>> nodes in Wikidata and data I generate myself.
>>>
>>> What technology do people use? Is there a recommended stack? I don't
>>> necessarily mean something like Ruby on Rails which is convention over
>>> configuration and "batteries included" by I don't mean Opengraph Virtuoso
>>> either, that's way too heavyweight.
>>>
>>> I'm running Ubuntu 17.10, a fairly popular distro. I can't seem to
>>> compile Redstone and anyway it appears unmaintained. Cayley looks cool but
>>> doesn't have its own on-disk back-end? (I don't understand that). Franz
>>> Allegrograph seems too commercial and lispy (maybe I'm wrong about this.).
>>> I don't want to use Jena because, um, Java.
>>>
>>> I can't find a single simple tutorial about using ruby-rdf to write to,
>>> modify, and query my own local triple-store.
>>>
>>> Most of the time I think it would be easier to define a relational model
>>> and map to triples on the fly and then I'd use tech that I'm familiar.
>>>
>>> For small projects what do people use? I don't want to spend a week
>>> setting up a local triple-store. I want something that is robust, I can set
>>> up nearly as easily as Rails, is actively maintained, and supports most of
>>> the current Semantic Web tech.
>>>
>>> Is there something obvious I'm not getting or that I'm overlooking?
>>>
>>> Thanks!
>>>     Anthony
>>>
>>
>
>
> --
> -Tom Johnson
>

Received on Wednesday, 1 November 2017 17:58:52 UTC