Skip to main content

jx-sqlite

JSON query expressions using SQLite

PyPI Latest Release 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.

Status

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

Jan 2024 - 91/320 tests ignored

Installation

pip install jx-sqlite

Code Example

The smoke test, found in the tests is a simple example of how to use this library.

Open a database

import jx_sqlite

table = (
    jx_sqlite
    .Container(filename="my.db")
    .get_or_create_facts("my_table")
    .add({"os":"linux", "value":42})
    .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

Good work by Rohit Kumar. You may see the end result on gsoc branch. Installation requires python2.7, and will require some version fixing to get running.

See the demonstration video

Work done up to the deadline of GSoC'17:

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-5.536.24035.tar.gz (62.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jx_sqlite-5.536.24035-py3-none-any.whl (109.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jx-sqlite-5.536.24035.tar.gz
  • Upload date:
  • Size: 62.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.6

File hashes

Hashes for jx-sqlite-5.536.24035.tar.gz
Algorithm Hash digest
SHA256 c70a77c77f5ca9f6a6ee722f34062d296b213ec75f124914b58b2f5ed0ea19b7
MD5 2f637bb57d2525fd60e1cbce70d0ad86
BLAKE2b-256 d13ba55e77a60f265287f4a04ba5f61475f5ba7b310ef850972d4fbb839b6197

See more details on using hashes here.

File details

Details for the file jx_sqlite-5.536.24035-py3-none-any.whl.

File metadata

File hashes

Hashes for jx_sqlite-5.536.24035-py3-none-any.whl
Algorithm Hash digest
SHA256 6c28feded15da447ebc8799e63951b45da185b8ed7caa36fd10c16d4b1e8b4ed
MD5 ac4f8551085b636a162a7f5281046bab
BLAKE2b-256 f7ad114898ffc6ead86cbbd22cef9d232f5902da5aef317124146e7ca0eef365

See more details on using hashes here.

Release history Release notifications | RSS feed

5.673.25037

2 files

5.626.24125

2 files

5.607.24116

2 files

5.588.24110

2 files

5.586.24095

2 files

5.579.24081

2 files

5.576.24080

2 files

5.575.24078

2 files

5.574.24077

2 files

5.560.24071

2 files

5.542.24038

2 files

5.540.24037

2 files

5.537.24036

2 files

This release

5.536.24035 This release

2 files

5.535.24035

2 files

5.534.24035

2 files

5.526.24033

1 file

5.506.24025

1 file

4.38.21125

1 file

3.42.20031

1 file

3.35.20029

1 file

1.12.20029

1 file

0.10.17243

1 file

0.10.17242

1 file

0.9.17206

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page