Name | rdflib JSON |
Version |
7.1.3
JSON |
| download |
home_page | https://github.com/RDFLib/rdflib |
Summary | RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information. |
upload_time | 2025-01-18 04:34:43 |
maintainer | RDFLib Team |
docs_url | None |
author | Daniel 'eikeon' Krech |
requires_python | <4.0.0,>=3.8.1 |
license | BSD-3-Clause |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|

RDFLib
======
[](https://github.com/RDFLib/rdflib/actions?query=branch%3Amain)
[](https://rdflib.readthedocs.io/en/latest/?badge=latest)
[](https://coveralls.io/r/RDFLib/rdflib?branch=main)
[](https://github.com/RDFLib/rdflib/stargazers)
[](https://pepy.tech/project/rdflib)
[](https://pypi.python.org/pypi/rdflib)
[](https://pypi.python.org/pypi/rdflib)
[](https://doi.org/10.5281/zenodo.6845245)
[](https://gitpod.io/#https://github.com/RDFLib/rdflib)
[](https://gitter.im/RDFLib/rdflib?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[](https://matrix.to/#/#RDFLib_rdflib:gitter.im)
RDFLib is a pure Python package for working with [RDF](http://www.w3.org/RDF/). RDFLib contains most things you need to work with RDF, including:
* parsers and serializers for RDF/XML, N3, NTriples, N-Quads, Turtle, TriX, Trig, JSON-LD and even HexTuples
* a Graph interface which can be backed by any one of a number of Store implementations
* Store implementations for in-memory, persistent on disk (Berkeley DB) and remote SPARQL endpoints
* additional Stores can be supplied via plugins
* a SPARQL 1.1 implementation - supporting SPARQL 1.1 Queries and Update statements
* SPARQL function extension mechanisms
## RDFlib Family of packages
The RDFlib community maintains many RDF-related Python code repositories with different purposes. For example:
* [rdflib](https://github.com/RDFLib/rdflib) - the RDFLib core
* [sparqlwrapper](https://github.com/RDFLib/sparqlwrapper) - a simple Python wrapper around a SPARQL service to remotely execute your queries
* [pyLODE](https://github.com/RDFLib/pyLODE) - An OWL ontology documentation tool using Python and templating, based on LODE
* [pySHACL](https://github.com/RDFLib/pySHACL) - A pure Python module which allows for the validation of RDF graphs against SHACL graphs
* [OWL-RL](https://github.com/RDFLib/OWL-RL) - A simple implementation of the OWL2 RL Profile which expands the graph with all possible triples that OWL RL defines.
Please see the list for all packages/repositories here:
* <https://github.com/RDFLib>
Help with maintenance of all of the RDFLib family of packages is always welcome and appreciated.
## Versions & Releases
* `main` branch in this repository is the current unstable release
* `7.1.3` current stable release, small improvements to 7.1.1
* `7.1.2` previously deleted release
* `7.1.1` previous stable release
* see <https://github.com/RDFLib/rdflib/releases/tag/7.1.1>
* `7.0.0` previous stable release, supports Python 3.8.1+ only.
* see [Releases](https://github.com/RDFLib/rdflib/releases)
* `6.x.y` supports Python 3.7+ only. Many improvements over 5.0.0
* see [Releases](https://github.com/RDFLib/rdflib/releases)
* `5.x.y` supports Python 2.7 and 3.4+ and is [mostly backwards compatible with 4.2.2](https://rdflib.readthedocs.io/en/stable/upgrade4to5.html).
See <https://github.com/RDFLib/rdflib/releases/> for the release details.
## Documentation
See <https://rdflib.readthedocs.io> for our documentation built from the code. Note that there are `latest`, `stable` and versioned builds, such as `5.0.0`, matching releases.
## Installation
The stable release of RDFLib may be installed with Python's package management tool *pip*:
$ pip install rdflib
Some features of RDFLib require optional dependencies which may be installed using *pip* extras:
$ pip install rdflib[berkeleydb,networkx,html,lxml,orjson]
Alternatively manually download the package from the Python Package
Index (PyPI) at https://pypi.python.org/pypi/rdflib
The current version of RDFLib is 7.1.3, see the ``CHANGELOG.md`` file for what's new in this release.
### Installation of the current main branch (for developers)
With *pip* you can also install rdflib from the git repository with one of the following options:
$ pip install git+https://github.com/rdflib/rdflib@main
or
$ pip install -e git+https://github.com/rdflib/rdflib@main#egg=rdflib
or from your locally cloned repository you can install it with one of the following options:
$ poetry install # installs into a poetry-managed venv
or
$ pip install -e .
## Getting Started
RDFLib aims to be a pythonic RDF API. RDFLib's main data object is a `Graph` which is a Python collection
of RDF *Subject, Predicate, Object* Triples:
To create graph and load it with RDF data from DBPedia then print the results:
```python
from rdflib import Graph
g = Graph()
g.parse('http://dbpedia.org/resource/Semantic_Web')
for s, p, o in g:
print(s, p, o)
```
The components of the triples are URIs (resources) or Literals
(values).
URIs are grouped together by *namespace*, common namespaces are included in RDFLib:
```python
from rdflib.namespace import DC, DCTERMS, DOAP, FOAF, SKOS, OWL, RDF, RDFS, VOID, XMLNS, XSD
```
You can use them like this:
```python
from rdflib import Graph, URIRef, Literal
from rdflib.namespace import RDFS, XSD
g = Graph()
semweb = URIRef('http://dbpedia.org/resource/Semantic_Web')
type = g.value(semweb, RDFS.label)
```
Where `RDFS` is the RDFS namespace, `XSD` the XML Schema Datatypes namespace and `g.value` returns an object of the triple-pattern given (or an arbitrary one if multiple exist).
Or like this, adding a triple to a graph `g`:
```python
g.add((
URIRef("http://example.com/person/nick"),
FOAF.givenName,
Literal("Nick", datatype=XSD.string)
))
```
The triple (in n-triples notation) `<http://example.com/person/nick> <http://xmlns.com/foaf/0.1/givenName> "Nick"^^<http://www.w3.org/2001/XMLSchema#string> .`
is created where the property `FOAF.givenName` is the URI `<http://xmlns.com/foaf/0.1/givenName>` and `XSD.string` is the
URI `<http://www.w3.org/2001/XMLSchema#string>`.
You can bind namespaces to prefixes to shorten the URIs for RDF/XML, Turtle, N3, TriG, TriX & JSON-LD serializations:
```python
g.bind("foaf", FOAF)
g.bind("xsd", XSD)
```
This will allow the n-triples triple above to be serialised like this:
```python
print(g.serialize(format="turtle"))
```
With these results:
```turtle
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
<http://example.com/person/nick> foaf:givenName "Nick"^^xsd:string .
```
New Namespaces can also be defined:
```python
dbpedia = Namespace('http://dbpedia.org/ontology/')
abstracts = list(x for x in g.objects(semweb, dbpedia['abstract']) if x.language=='en')
```
See also [./examples](./examples)
## Features
The library contains parsers and serializers for RDF/XML, N3,
NTriples, N-Quads, Turtle, TriX, JSON-LD, RDFa and Microdata.
The library presents a Graph interface which can be backed by
any one of a number of Store implementations.
This core RDFLib package includes store implementations for
in-memory storage and persistent storage on top of the Berkeley DB.
A SPARQL 1.1 implementation is included - supporting SPARQL 1.1 Queries and Update statements.
RDFLib is open source and is maintained on [GitHub](https://github.com/RDFLib/rdflib/). RDFLib releases, current and previous
are listed on [PyPI](https://pypi.python.org/pypi/rdflib/)
Multiple other projects are contained within the RDFlib "family", see <https://github.com/RDFLib/>.
## Running tests
### Running the tests on the host
Run the test suite with `pytest`.
```shell
poetry install
poetry run pytest
```
### Running test coverage on the host with coverage report
Run the test suite and generate a HTML coverage report with `pytest` and `pytest-cov`.
```shell
poetry run pytest --cov
```
### Viewing test coverage
Once tests have produced HTML output of the coverage report, view it by running:
```shell
poetry run pytest --cov --cov-report term --cov-report html
python -m http.server --directory=htmlcov
```
## Contributing
RDFLib survives and grows via user contributions!
Please read our [contributing guide](https://rdflib.readthedocs.io/en/latest/CONTRIBUTING.html) and [developers guide](https://rdflib.readthedocs.io/en/latest/developers.html) to get started.
Please consider lodging Pull Requests here:
* <https://github.com/RDFLib/rdflib/pulls>
To get a development environment consider using Gitpod or Google Cloud Shell.
[](https://gitpod.io/#https://github.com/RDFLib/rdflib)
[](https://shell.cloud.google.com/cloudshell/editor?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2FRDFLib%2Frdflib&cloudshell_git_branch=main&cloudshell_open_in_editor=README.md)
You can also raise issues here:
* <https://github.com/RDFLib/rdflib/issues>
## Support & Contacts
For general "how do I..." queries, please use https://stackoverflow.com and tag your question with `rdflib`.
Existing questions:
* <https://stackoverflow.com/questions/tagged/rdflib>
If you want to contact the rdflib maintainers, please do so via:
* the rdflib-dev mailing list: <https://groups.google.com/group/rdflib-dev>
* the chat, which is available at [gitter](https://gitter.im/RDFLib/rdflib) or via matrix [#RDFLib_rdflib:gitter.im](https://matrix.to/#/#RDFLib_rdflib:gitter.im)
Raw data
{
"_id": null,
"home_page": "https://github.com/RDFLib/rdflib",
"name": "rdflib",
"maintainer": "RDFLib Team",
"docs_url": null,
"requires_python": "<4.0.0,>=3.8.1",
"maintainer_email": "rdflib-dev@googlegroups.com",
"keywords": null,
"author": "Daniel 'eikeon' Krech",
"author_email": "eikeon@eikeon.com",
"download_url": "https://files.pythonhosted.org/packages/96/12/f43307e7b1f871ed5424fc6eff1fb8c85637dbaed6a401748c2b72c97d7a/rdflib-7.1.3.tar.gz",
"platform": null,
"description": " \n\nRDFLib\n======\n[](https://github.com/RDFLib/rdflib/actions?query=branch%3Amain)\n[](https://rdflib.readthedocs.io/en/latest/?badge=latest)\n[](https://coveralls.io/r/RDFLib/rdflib?branch=main)\n\n[](https://github.com/RDFLib/rdflib/stargazers)\n[](https://pepy.tech/project/rdflib)\n[](https://pypi.python.org/pypi/rdflib)\n[](https://pypi.python.org/pypi/rdflib)\n[](https://doi.org/10.5281/zenodo.6845245)\n\n[](https://gitpod.io/#https://github.com/RDFLib/rdflib)\n[](https://gitter.im/RDFLib/rdflib?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)\n[](https://matrix.to/#/#RDFLib_rdflib:gitter.im)\n\nRDFLib is a pure Python package for working with [RDF](http://www.w3.org/RDF/). RDFLib contains most things you need to work with RDF, including:\n\n* parsers and serializers for RDF/XML, N3, NTriples, N-Quads, Turtle, TriX, Trig, JSON-LD and even HexTuples\n* a Graph interface which can be backed by any one of a number of Store implementations\n* Store implementations for in-memory, persistent on disk (Berkeley DB) and remote SPARQL endpoints\n * additional Stores can be supplied via plugins \n* a SPARQL 1.1 implementation - supporting SPARQL 1.1 Queries and Update statements\n* SPARQL function extension mechanisms\n\n## RDFlib Family of packages\nThe RDFlib community maintains many RDF-related Python code repositories with different purposes. For example:\n\n* [rdflib](https://github.com/RDFLib/rdflib) - the RDFLib core\n* [sparqlwrapper](https://github.com/RDFLib/sparqlwrapper) - a simple Python wrapper around a SPARQL service to remotely execute your queries\n* [pyLODE](https://github.com/RDFLib/pyLODE) - An OWL ontology documentation tool using Python and templating, based on LODE\n* [pySHACL](https://github.com/RDFLib/pySHACL) - A pure Python module which allows for the validation of RDF graphs against SHACL graphs\n* [OWL-RL](https://github.com/RDFLib/OWL-RL) - A simple implementation of the OWL2 RL Profile which expands the graph with all possible triples that OWL RL defines.\n\nPlease see the list for all packages/repositories here:\n\n* <https://github.com/RDFLib>\n\nHelp with maintenance of all of the RDFLib family of packages is always welcome and appreciated.\n\n## Versions & Releases\n\n* `main` branch in this repository is the current unstable release\n* `7.1.3` current stable release, small improvements to 7.1.1\n* `7.1.2` previously deleted release\n* `7.1.1` previous stable release\n * see <https://github.com/RDFLib/rdflib/releases/tag/7.1.1>\n* `7.0.0` previous stable release, supports Python 3.8.1+ only.\n * see [Releases](https://github.com/RDFLib/rdflib/releases)\n* `6.x.y` supports Python 3.7+ only. Many improvements over 5.0.0\n * see [Releases](https://github.com/RDFLib/rdflib/releases)\n* `5.x.y` supports Python 2.7 and 3.4+ and is [mostly backwards compatible with 4.2.2](https://rdflib.readthedocs.io/en/stable/upgrade4to5.html).\n\nSee <https://github.com/RDFLib/rdflib/releases/> for the release details.\n\n## Documentation\nSee <https://rdflib.readthedocs.io> for our documentation built from the code. Note that there are `latest`, `stable` and versioned builds, such as `5.0.0`, matching releases.\n\n## Installation\nThe stable release of RDFLib may be installed with Python's package management tool *pip*:\n\n $ pip install rdflib\n\nSome features of RDFLib require optional dependencies which may be installed using *pip* extras:\n\n $ pip install rdflib[berkeleydb,networkx,html,lxml,orjson]\n\nAlternatively manually download the package from the Python Package\nIndex (PyPI) at https://pypi.python.org/pypi/rdflib\n\nThe current version of RDFLib is 7.1.3, see the ``CHANGELOG.md`` file for what's new in this release.\n\n### Installation of the current main branch (for developers)\n\nWith *pip* you can also install rdflib from the git repository with one of the following options:\n\n $ pip install git+https://github.com/rdflib/rdflib@main\n\nor\n\n $ pip install -e git+https://github.com/rdflib/rdflib@main#egg=rdflib\n\nor from your locally cloned repository you can install it with one of the following options:\n\n $ poetry install # installs into a poetry-managed venv\n\nor\n\n $ pip install -e .\n\n## Getting Started\nRDFLib aims to be a pythonic RDF API. RDFLib's main data object is a `Graph` which is a Python collection\nof RDF *Subject, Predicate, Object* Triples:\n\nTo create graph and load it with RDF data from DBPedia then print the results:\n\n```python\nfrom rdflib import Graph\ng = Graph()\ng.parse('http://dbpedia.org/resource/Semantic_Web')\n\nfor s, p, o in g:\n print(s, p, o)\n```\nThe components of the triples are URIs (resources) or Literals\n(values).\n\nURIs are grouped together by *namespace*, common namespaces are included in RDFLib:\n\n```python\nfrom rdflib.namespace import DC, DCTERMS, DOAP, FOAF, SKOS, OWL, RDF, RDFS, VOID, XMLNS, XSD\n```\n\nYou can use them like this:\n\n```python\nfrom rdflib import Graph, URIRef, Literal\nfrom rdflib.namespace import RDFS, XSD\n\ng = Graph()\nsemweb = URIRef('http://dbpedia.org/resource/Semantic_Web')\ntype = g.value(semweb, RDFS.label)\n```\nWhere `RDFS` is the RDFS namespace, `XSD` the XML Schema Datatypes namespace and `g.value` returns an object of the triple-pattern given (or an arbitrary one if multiple exist).\n\nOr like this, adding a triple to a graph `g`:\n\n```python\ng.add((\n URIRef(\"http://example.com/person/nick\"),\n FOAF.givenName,\n Literal(\"Nick\", datatype=XSD.string)\n))\n```\nThe triple (in n-triples notation) `<http://example.com/person/nick> <http://xmlns.com/foaf/0.1/givenName> \"Nick\"^^<http://www.w3.org/2001/XMLSchema#string> .`\nis created where the property `FOAF.givenName` is the URI `<http://xmlns.com/foaf/0.1/givenName>` and `XSD.string` is the\nURI `<http://www.w3.org/2001/XMLSchema#string>`.\n\nYou can bind namespaces to prefixes to shorten the URIs for RDF/XML, Turtle, N3, TriG, TriX & JSON-LD serializations:\n\n ```python\ng.bind(\"foaf\", FOAF)\ng.bind(\"xsd\", XSD)\n```\nThis will allow the n-triples triple above to be serialised like this:\n ```python\nprint(g.serialize(format=\"turtle\"))\n```\n\nWith these results:\n```turtle\nPREFIX foaf: <http://xmlns.com/foaf/0.1/>\nPREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n\n<http://example.com/person/nick> foaf:givenName \"Nick\"^^xsd:string .\n```\n\nNew Namespaces can also be defined:\n\n```python\ndbpedia = Namespace('http://dbpedia.org/ontology/')\n\nabstracts = list(x for x in g.objects(semweb, dbpedia['abstract']) if x.language=='en')\n```\n\nSee also [./examples](./examples)\n\n\n## Features\nThe library contains parsers and serializers for RDF/XML, N3,\nNTriples, N-Quads, Turtle, TriX, JSON-LD, RDFa and Microdata.\n\nThe library presents a Graph interface which can be backed by\nany one of a number of Store implementations.\n\nThis core RDFLib package includes store implementations for\nin-memory storage and persistent storage on top of the Berkeley DB.\n\nA SPARQL 1.1 implementation is included - supporting SPARQL 1.1 Queries and Update statements.\n\nRDFLib is open source and is maintained on [GitHub](https://github.com/RDFLib/rdflib/). RDFLib releases, current and previous\nare listed on [PyPI](https://pypi.python.org/pypi/rdflib/)\n\nMultiple other projects are contained within the RDFlib \"family\", see <https://github.com/RDFLib/>.\n\n## Running tests\n\n### Running the tests on the host\n\nRun the test suite with `pytest`.\n```shell\npoetry install\npoetry run pytest\n```\n\n### Running test coverage on the host with coverage report\n\nRun the test suite and generate a HTML coverage report with `pytest` and `pytest-cov`.\n```shell\npoetry run pytest --cov\n```\n\n### Viewing test coverage\n\nOnce tests have produced HTML output of the coverage report, view it by running:\n```shell\npoetry run pytest --cov --cov-report term --cov-report html\npython -m http.server --directory=htmlcov\n```\n\n## Contributing\n\nRDFLib survives and grows via user contributions!\nPlease read our [contributing guide](https://rdflib.readthedocs.io/en/latest/CONTRIBUTING.html) and [developers guide](https://rdflib.readthedocs.io/en/latest/developers.html) to get started.\nPlease consider lodging Pull Requests here:\n\n* <https://github.com/RDFLib/rdflib/pulls>\n\nTo get a development environment consider using Gitpod or Google Cloud Shell.\n\n[](https://gitpod.io/#https://github.com/RDFLib/rdflib)\n[](https://shell.cloud.google.com/cloudshell/editor?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2FRDFLib%2Frdflib&cloudshell_git_branch=main&cloudshell_open_in_editor=README.md)\n\nYou can also raise issues here:\n\n* <https://github.com/RDFLib/rdflib/issues>\n\n## Support & Contacts\nFor general \"how do I...\" queries, please use https://stackoverflow.com and tag your question with `rdflib`.\nExisting questions:\n\n* <https://stackoverflow.com/questions/tagged/rdflib>\n\nIf you want to contact the rdflib maintainers, please do so via:\n\n* the rdflib-dev mailing list: <https://groups.google.com/group/rdflib-dev>\n* the chat, which is available at [gitter](https://gitter.im/RDFLib/rdflib) or via matrix [#RDFLib_rdflib:gitter.im](https://matrix.to/#/#RDFLib_rdflib:gitter.im)\n",
"bugtrack_url": null,
"license": "BSD-3-Clause",
"summary": "RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.",
"version": "7.1.3",
"project_urls": {
"Documentation": "https://rdflib.readthedocs.org/",
"Homepage": "https://github.com/RDFLib/rdflib",
"Repository": "https://github.com/RDFLib/rdflib"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9c3cf508a9b346078ea0bd49c8261430204fcfb4150352d51fa2a54a4d9eacda",
"md5": "d656319c75af676495dc1aa0e29a86d4",
"sha256": "5402310a9f0f3c07d453d73fd0ad6ba35616286fe95d3670db2b725f3f539673"
},
"downloads": -1,
"filename": "rdflib-7.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d656319c75af676495dc1aa0e29a86d4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0.0,>=3.8.1",
"size": 564909,
"upload_time": "2025-01-18T04:34:29",
"upload_time_iso_8601": "2025-01-18T04:34:29.120695Z",
"url": "https://files.pythonhosted.org/packages/9c/3c/f508a9b346078ea0bd49c8261430204fcfb4150352d51fa2a54a4d9eacda/rdflib-7.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9612f43307e7b1f871ed5424fc6eff1fb8c85637dbaed6a401748c2b72c97d7a",
"md5": "0d140c37fc940bbb0b7c94cf50b2ba9b",
"sha256": "f3dcb4c106a8cd9e060d92f43d593d09ebc3d07adc244f4c7315856a12e383ee"
},
"downloads": -1,
"filename": "rdflib-7.1.3.tar.gz",
"has_sig": false,
"md5_digest": "0d140c37fc940bbb0b7c94cf50b2ba9b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0.0,>=3.8.1",
"size": 4867170,
"upload_time": "2025-01-18T04:34:43",
"upload_time_iso_8601": "2025-01-18T04:34:43.542855Z",
"url": "https://files.pythonhosted.org/packages/96/12/f43307e7b1f871ed5424fc6eff1fb8c85637dbaed6a401748c2b72c97d7a/rdflib-7.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-18 04:34:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "RDFLib",
"github_project": "rdflib",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "rdflib"
}