7 releases

0.2.4 Nov 11, 2023
0.2.3 Oct 14, 2023
0.2.0 Sep 18, 2023
0.1.1 Sep 17, 2023

#135 in Testing

Download history 2/week @ 2024-02-18 5/week @ 2024-02-25 96/week @ 2024-03-31

96 downloads per month

MIT license

62KB
1.5K SLoC

triples

Experimental Rust lib to store any data in triple format.

Features

  • embedded
  • async
  • cli db maintenance tool
  • RDF / Turtle
  • import / export of non-RDF data

Overview

  • Rust API
  • stores subject, predicate, and object where
    • subject is always an RDF name
    • predicate is always an RDF name
    • object is always a UTF string

Install

cargo install triples

or

see crate

Usage

For API usage, see the unit tests in db_api for now.

For cli usage:

triples -h
A lib and cli for storing data triples

Usage: triples [OPTIONS] <COMMAND>

Commands:
  import-turtle
  export-turtle
  import-csv
  export-csv
  help           Print this message or the help of the given subcommand(s)

Options:
  -d, --db-location <DB_LOCATION>  [default: /tmp/triples.db]
  -h, --help                       Print help
  -V, --version                    Print version

import csv and prepend NS prefixes

cat ../vssgen/vss_sm.csv | triples -d /tmp/vss.db import-csv --subject-default-ns https://myvss.com/id --predicate-default-ns https://myvss.com/data --skip-headers

export ttl

triples --db-location /tmp/vss.db export-turtle
@prefix ns1: <https://myvss.com/id/> .

@prefix ns2: <https://myvss.com/data/> .

ns1:d654c9bc-37d7-425e-945b-41a4440da236
    ns2:has_chassis "1ad84bfb-2017-4c42-b28f-de938755cb00" ;
    ns2:timestamp "2023-09-17 21:07:36" ;
    ns2:type "vehicle" ;
    ns2:has_drivetrain "8db9fa98-5017-43d3-accd-bebe822a4066" ;
    ns2:vehicle_id "0" ; .

ns1:1ad84bfb-2017-4c42-b28f-de938755cb00
    ns2:brake_status "False" ;
    ns2:type "chassis" ;
    ns2:speed "79" ; .

ns1:8db9fa98-5017-43d3-accd-bebe822a4066
    ns2:engine_temperature "106" ;
    ns2:fuel_level "56" ;
    ns2:type "drivetrain" ;
    ns2:battery_level "3" ; .

TODO

  • bulk loading and exporting via cli
  • normalizes RDF names
  • normalizing object values
  • import / export of RDF Turtle *.tll format
  • import / export of triple csv *.csv format
  • meaningful prefix names on export
  • better export tests
  • import of arbitrary column csv *.csv format
  • import of arbitrary json *.json format
  • import of arbitrary jsonl *.jsonl format
  • txn control via api
  • insert performance
  • SparkQL

PRs welcome

Dependencies

~20–39MB
~621K SLoC