Skip to content

Commit

Permalink
Merge branch 'setstore' of https://github.com/osma/rdflib into reunif…
Browse files Browse the repository at this point in the history
…ication
  • Loading branch information
gromgull committed Apr 24, 2013
2 parents 84d0654 + 5837b7c commit 9f0814e
Show file tree
Hide file tree
Showing 8 changed files with 305 additions and 418 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ are listed on [PyPi](pypi.python.org/pypi/rdflib/)

RDFLib has a plugin-architecture for store-implementation, as well as parsers/serializers, several other projects exist which extend RDFLib features:

* [rdfextras](https://github.com/RDFLib/rdfextras) - for SPARQL Support
* [rdflib-sparql](https://github.com/RDFLib/rdflib-sparql) - for SPARQL Support
* [rdflib-json](https://github.com/RDFLib/rdflib-jsonld) - Serializer and parser for [json-ld](http://json-ld.org)
* [rdflib-sparqlstore](https://github.com/RDFLib/rdflib-sparqlstore) - a store implementation on top of a SPARQL endpoint accessed over HTTP
* [rdflib-mysql](https://github.com/RDFLib/rdflib-mysql) - a store implementation of top of MySQL

* [rdfextras](https://github.com/RDFLib/rdfextras) - additional experimental plugins and tools


Support
-------
Expand All @@ -84,11 +86,6 @@ Continuous integration status details available from travis.ci:

[![Build Status](https://travis-ci.org/RDFLib/rdflib.png?branch=master)](https://travis-ci.org/RDFLib/rdflib)

The RDFExtras project offers several additional stores as well as a
SPARQL engine for use with RDFLib:

https://github.com/RDFLib/rdfextras/

The documentation can be built by doing::

$ python setup.py build_sphinx
Expand Down
3 changes: 1 addition & 2 deletions docs/assorted_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ fold_sha1.py
might be easier to do some operations on.
"""
from rdflib.graph import Graph
from rdflib import Namespace
from rdflib import Graph, Namespace
FOAF = Namespace("http://xmlns.com/foaf/0.1/")
STABLE = Namespace("http://example.com/person/mbox_sha1sum/")
Expand Down
7 changes: 3 additions & 4 deletions docs/gettingstarted.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RDFLib is open source and is maintained in a
`GitHub <http://github.com/RDFLib/rdflib/>`_ repository. RDFLib releases, current and previous
are listed on `PyPi <pypi.python.org/pypi/rdflib/>`_

RDFLib may be easy_installed:
The best way to install RDFLib is to use easy_install or pip:

.. code-block :: bash
Expand Down Expand Up @@ -57,9 +57,7 @@ A more extensive example:

.. code-block:: python
from rdflib.graph import Graph
from rdflib import Literal, BNode, Namespace
from rdflib import RDF
from rdflib import Graph, Literal, BNode, Namespace, RDF
g = Graph()
Expand Down Expand Up @@ -89,3 +87,4 @@ A more extensive example:
for mbox in g.objects(person, FOAF["mbox"]):
print(mbox)
Additional examples can be found in the examples folder in the source distribution.
3 changes: 1 addition & 2 deletions docs/graphs_bnodes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ Clarifying the query more precisely:

.. code-block:: pycon
>>> from rdflib.graph import Graph, ConjunctiveGraph
>>> from rdflib import URIRef
>>> from rdflib import Graph, ConjunctiveGraph, URIRef
[1]

Expand Down
2 changes: 1 addition & 1 deletion docs/intro_to_graphs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ In an interactive python interpreter, try this:

.. code-block:: pycon
>>> from rdflib.graph import Graph
>>> from rdflib import Graph
>>> g = Graph()
>>> g.parse("demo.nt", format="nt")
<Graph identifier=HCbubHJy0 (<class 'rdflib.graph.Graph'>)>
Expand Down
14 changes: 11 additions & 3 deletions docs/intro_to_sparql.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ You might parse some files into a new graph (see `Introduction to parsing <intro

.. code-block:: python
from rdflib.graph import Graph
from rdflib import Graph
g = Graph()
g.parse("http://bigasterisk.com/foaf.rdf")
g.parse("http://www.w3.org/People/Berners-Lee/card.rdf")
Expand All @@ -20,7 +20,7 @@ LiveJournal produces FOAF data for their users, but they seem to use ``foaf:memb

.. code-block:: python
from rdflib.namespace import Namespace
from rdflib import Namespace
FOAF = Namespace("http://xmlns.com/foaf/0.1/")
g.parse("http://danbri.livejournal.com/data/foaf")
[g.add((s, FOAF['name'], n))
Expand All @@ -31,12 +31,20 @@ Run a Query

The ``rdflib`` package concentrates on providing the core RDF types and interfaces for working with RDF. As indicated in the introduction, the package defines a plugin interface (for parsers, stores, and serializers) that other packages can use to implement parsers, stores, and serializers that will plug into the ``rdflib`` package.

In order to perform SPARQL queries, you need to install the companion ``rdfextras`` package which includes a SPARQL plugin implementation:
In order to perform SPARQL queries, you need to install a SPARQL plugin implementation: either the old ``rdfextras`` package, or the new ``rdflib-sparql``, i.e. either:

.. code-block:: bash
$ easy_install rdfextras
or

.. code-block:: bash
$ easy_install rdflib-sparql
If installed with setuptools this automatically binds the the imported SPARQL query processor implementation to the :meth:`rdflib.graph.Graph.query` method, which can then be passed a SPARQL query (a string). When called, the :meth:`~rdflib.graph.Graph.query` method returns a SPARQLQuery object whose ``result`` attribute is a list of results.

Continuing the example...
Expand Down
36 changes: 20 additions & 16 deletions docs/persistence.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,24 @@ Stores currently supported in rdflib
Usage
^^^^^

Store instances can be created with the :meth:`plugin` function:
Most cases passing the name of the store to the Graph constrcutor is enough:

.. code-block:: python
from rdflib import plugin
from rdflib.store import Store
plugin.get('.. one of the supported Stores ..',Store)(identifier=.. id of conjunctive graph ..)
from rdflib import Graph
graph = Graph(store='Sleepycat')
If additional configuration of the store is required, a store instances can be created with the :meth:`plugin` function:

.. code-block:: python
from rdflib import plugin, Store, Graph
store = plugin.get('.. one of the supported Stores ..',Store)(identifier=.. id of conjunctive graph ..)
graph = Graph(store=store)
Additional store plugins in ``rdfextras``
Expand All @@ -44,24 +55,17 @@ remove the database files that were created.

.. code-block:: python
import rdflib
from rdflib.graph import ConjunctiveGraph as Graph
from rdflib import plugin
from rdflib.store import Store, NO_STORE, VALID_STORE
from rdflib.namespace import Namespace
from rdflib.term import Literal
from rdflib.term import URIRef
from rdflib import ConjunctiveGraph, plugin, Namespace, Literal, URIRef, Store
from rdflib.store import NO_STORE, VALID_STORE
from tempfile import mkdtemp
default_graph_uri = "http://rdflib.net/rdfstore"
configString = "/var/tmp/rdfstore"
# Get the Sleepycat plugin.
store = plugin.get('Sleepycat', Store)('rdfstore')
# Open previously created store, or create it if it doesn't exist yet
graph = Graph(store="Sleepycat",
identifier = URIRef(default_graph_uri))
graph = ConjunctiveGraph(store="Sleepycat",
identifier = default_graph_uri)
path = mkdtemp()
rt = graph.open(path, create=False)
if rt == NO_STORE:
Expand Down
Loading

0 comments on commit 9f0814e

Please sign in to comment.