Skip to content


Subversion checkout URL

You can clone with
Download ZIP
This fork is unmaintained. DataObjects-backed repositories for RDF.rb
Branch: master
Pull request Compare This branch is 29 commits behind ruby-rdf:master.
Failed to load latest commit information.
lib/rdf Relax RDF.rb dependency to >= from ~>
spec Update sqlite3 to use new durable specs
.gitignore Imported a .gitignore
.yardopts Typos! Typos! Typos will be the death of me!
AUTHORS More paperwork: README links to, AUTHORS file, adjust gemspec
CHANGELOG Update changelog
README Officially deprecate 1.8.6 in the README
Rakefile Require 'rdf' in the console task
UNLICENSE Initial commit
VERSION Relax RDF.rb dependency to >= from ~>
rdf-do.gemspec Relax RDF.rb dependency to >= from ~>


DataObjects-backed RDF.rb repository, aiming for a simple use case and currently targeting SQLite and Postgres.

This was written for a tutorial, and is thus a pretty naive implementation so far. RDF::DataObjects stores triples in a simple subject, predicate, object, context table. Don't try to back a big website with it yet. Nonetheless, it works, and it passes all its tests on Heroku as well.


repository = "sqlite3:test.db"
repository.count              #=> 1

You can use any DataObjects compatible connection options to create a new repository, but only SQLite3 and Postgres are implemented for now. The different databases are just different enough with their handling of unique constraints that some database-specific work is required for a new adapter, but it's not much.


The greatly preferred installation method is via RubyGems:

$ sudo gem install rdf-do

Manual downloads are available at

Ruby 1.8.6 is not supported, but the tests pass with the backports gem. Godspeed.


require 'do_postgres'
require 'do_sqlite3'
repo = "postgres://localhost/database"
repo = "sqlite3:test.db"


Your repository is a fully-functional RDF.rb RDF::Repository. As with any RDF.rb repository, this includes the mixins RDF::Enumerable, RDF::Mutable, RDF::Durable, and RDF::Queryable. Please see for more information.


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

repo ='sqlite3:test.db')
# repo = 'postgres://postgres@server/database'
# heroku_repo =['DATABASE_URL'])

# How many statements did we have?
#=> 10

# Get the URI of the first subject
jhacker = repo.first.subject
#=> #<RDF::URI(>

# Delete everything to do with it
jhacker_statements = repo.query(:subject => jhacker) 
repo.delete *jhacker_statements
#=> 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
#=> 10


The main project page is on Github, at You can get a working copy of the source tree with:

$ git clone git://

Or with:

$ wget


The preferred method to report issues is the issue queue at You'll get the the most attention if you submit a failing test for a bug, or a pending test for a feature.

We'd also like to hear from you on the mailing list:


Something went wrong with that request. Please try again.