Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
/ pyrdb2rdf Public archive

A Python library for RDB2RDF Direct Mapping and R2RML.

License

Notifications You must be signed in to change notification settings

nisavid/pyrdb2rdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyRDB2RDF

PyRDB2RDF provides RDFLib with an interface to relational databases as RDF stores. The underlying data is accessed via SQLAlchemy. It is mapped to RDF according to the specifications of RDB2RDF. The corresponding RDF graph is represented as an RDFLib graph.

Translating from relational data to RDF via direct mapping is currently supported. Translating in the other direction and mapping with R2RML are planned but not yet implemented.

Installation

pip install rdb2rdf

Examples

Serializing a database as N-Triples

Suppose the local PostgreSQL database test_dm contains data that we want to translate to RDF and serialize as N-Triples. The following code achieves that.

import rdflib as _rdf
import sqlalchemy as _sqla

db_str = 'postgresql://testuser:testpasswd@localhost/testdb'
db = _sqla.create_engine(db_str)
graph = _rdf.Graph('rdb2rdf_dm')
graph.open(db)

print(graph.serialize(format='nt'))

About

A Python library for RDB2RDF Direct Mapping and R2RML.

Resources

License

Stars

Watchers

Forks

Packages

No packages published