Git Product home page Git Product logo

rdf-to-sqlite's Introduction

rdf-to-sqlite

PyPI Changelog Tests License

Load the contents of an RDF file into a set of SQLite database tables.

$ rdf-to-sqlite --help
Usage: rdf-to-sqlite [OPTIONS] DB_PATH RDF_FILE

  Convert an RDF file to SQLite

Options:
  --version                       Show the version and exit.
  --context TEXT                  URL or file containing a JSON-LD context
  --format [html|n3|nquads|nt|rdfa|rdfa1.0|rdfa1.1|trix|turtle|xml|json-ld]
                                  RDF serialization format  [required]
  --help                          Show this message and exit.

Usage

Given an RDF file example.ttl containing the following:

@prefix ns1: <http://schema.org/> .

<http://www.janedoe.com/> a ns1:Person ;
    ns1:jobTitle "Professor" ;
    ns1:name "Jane Doe" ;
    ns1:telephone "(425) 123-4567" .

Running this command:

$ rdf-to-sqlite example.db example.ttl --format turtle --context https://schema.org/docs/jsonldcontext.jsonld

Will create a database file example.db with this schema, using a property table approach to RDF storage on relational databases [1], [2]:

CREATE TABLE [Person] (
   [@context] TEXT,
   [id] TEXT PRIMARY KEY,
   [jobTitle] TEXT,
   [name] TEXT,
   [telephone] TEXT
);
CREATE TABLE [Person_rdf:type] (
   [subject] TEXT,
   [predicate] TEXT,
   [object] TEXT,
   PRIMARY KEY ([subject], [object])
);

Acknowledgements

Thanks to Simon Willison for the inspiration from his work on Datasette and more specifically yaml-to-sql, which was a very useful example for how to package this up properly.

References

[1] Sakr, S. and Al-Naymat, G., 2010. Relational processing of RDF queries: a survey. ACM SIGMOD Record, 38(4), pp.23-28.

[2] Ali, W., Saleem, M., Yao, B., Hogan, A. and Ngomo, A.C.N., 2020. Storage, indexing, query processing, and benchmarking in centralized and distributed rdf engines: A survey. arXiv preprint arXiv:2009.10331.

rdf-to-sqlite's People

Contributors

bradleypallen avatar

Stargazers

Simon Willison avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.