Skip to main content

jx-sqlite

JSON query expressions using SQLite

https://travis-ci.org/klahnakoski/jx-sqlite.svg?branch=master

Branch Status
master Build Status
dev Build Status

Summary

This library will manage your database schema to store JSON documents. You get all the speed of a well-formed database schema without the schema migration headaches.

https://www.youtube.com/watch?v=0_YLzb7BegI&list=PLSE8ODhjZXja7K1hjZ01UTVDnGQdx5v5U&index=26&t=260s

Status

Significant updates to the supporting libraries has broken this ode. It still works works for the simple cases that require it

Jan 2020 - 96/283 test failing

Installation

pip install jx-sqlite

Code Example

Open a database

container = Container()

Declare a table

table = container.get_or_create_facts("my_table")

Pour JSON documents into it

table.add({"os":"linux", "value":42})

Query the table

table.query({
    "select": "os", 
    "where": {"gt": {"value": 0}}
})

More

An attempt to store JSON documents in SQLite so that they are accessible via SQL. The hope is this will serve a basis for a general document-relational map (DRM), and leverage the database's query optimizer. jx-sqlite is also responsible for making the schema, and changing it dynamically as new JSON schema are encountered and to ensure that the old queries against the new schema have the same meaning.

The most interesting, and most important feature is that we query nested object arrays as if they were just another table. This is important for two reasons:

  1. Inner objects {"a": {"b": 0}} are a shortcut for nested arrays {"a": [{"b": 0}]}, plus
  2. Schemas can be expanded from one-to-one to one-to-many {"a": [{"b": 0}, {"b": 1}]}.

Motivation

JSON is a nice format to store data, and it has become quite prevalent. Unfortunately, databases do not handle it well, often a human is required to declare a schema that can hold the JSON before it can be queried. If we are not overwhelmed by the diversity of JSON now, we soon will be. There will be more JSON, of more different shapes, as the number of connected devices( and the information they generate) continues to increase.

Contributing

Contributions are always welcome! The best thing to do is find a failing test, and try to fix it.

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

$ git clone https://github.com/mozilla/jx-sqlite
$ cd jx-sqlite

Running tests

There are over 200 tests used to confirm the expected behaviour: They test a variety of JSON forms, and the queries that can be performed on them. Most tests are further split into three different output formats ( list, table and cube).

export PYTHONPATH=.
python -m unittest discover -v -s tests

Technical Docs

License

This project is licensed under Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

History

Sep 2018 - Upgrade libs, start refactoring to work with other libs

Dec 2017 - A number of tests were added, but they do not pass.

Sep 2017 - GSoC work completed, all but a few tests pass.

GSOC

Work done upto the deadline of GSoC'17:

More Documentation

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jx-sqlite-4.38.21125.tar.gz (311.3 kB view details)

Uploaded Source

File details

Details for the file jx-sqlite-4.38.21125.tar.gz.

File metadata

  • Download URL: jx-sqlite-4.38.21125.tar.gz
  • Upload date:
  • Size: 311.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.8

File hashes

Hashes for jx-sqlite-4.38.21125.tar.gz
Algorithm Hash digest
SHA256 09074022b1f6434c02a29239e3fb8c81e1d962d9549e867003ec78f47fb77009
MD5 98613e7f032b8cf6fbd189fd9989f68a
BLAKE2b-256 750bab62e374e0539d6133595b49c09da2f4e85c8e1626175653ed7defc0a7ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page