Skip to main content

jx-sqlite

JSON query expressions using SQLite

PyPI Latest Release Build Status Coverage 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 - 118 of 334 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.

import jx_sqlite

table = (
    jx_sqlite
    .Container(filename="my.db")
    .get_or_create_facts("my_table")
    .insert([{"os": "linux", "value": 42}])
    .query({
        "select": "os",
        "where": {"gt": {"value": 0}}
    })
)

More

This project is 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 responsible for expanding the schema dynamically as new JSON documents are encountered. It also strives to ensure old queries against the new schema have the same meaning; the same results.

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/klahnakoski/jx-sqlite
$ cd jx-sqlite

Running tests

There are over 300 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).

The requirements.lock file is the last successful combination that passed all tests, despite the version conflicts.

python.exe -m pip install --no-deps -r tests\requirements.lock

Linux

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

Windows

set PYTHONPATH=.;vendor
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

Jan 2024 - Attempt to resurrect this project (118 of 334 tests ignored)

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:

Metadata

Release files for jx-sqlite 5.673.25037

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jx-sqlite 5.673.25037
File Size Uploaded Provenance
jx_sqlite-5.673.25037.tar.gz 61.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for jx-sqlite 5.673.25037
File Interpreter ABI Platform
jx_sqlite-5.673.25037-py3-none-any.whl Python 3 none any Details

Total release size: 170.8 kB

Release files / jx_sqlite-5.673.25037.tar.gz

Download URL jx_sqlite-5.673.25037.tar.gz
Size 61.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b0f7d25a1edcf241fd67824da3146d3ac33e17c96f05996060aa73e75bc784ad
BLAKE2b-256 checksum
How to use checksums
acd853b83599cf5b76cf1b0286f39de21d31392b01745ee987b5f92c603e2a7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.6

Release files / jx_sqlite-5.673.25037-py3-none-any.whl

Download URL jx_sqlite-5.673.25037-py3-none-any.whl
Size 109.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4535cf9c4569a3dd6506af34886426d1bc21fc6b92090305aea83e273a7632be
BLAKE2b-256 checksum
How to use checksums
6baade17f837963435dca5abb61e781d2506f55db4a3e9ae53a734bf846dda1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.6

Security for jx-sqlite 5.673.25037

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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