Skip to main content

JSON to SQL query generator

Project description

jsqlib

JSON to SQL query generator.

pipeline status PyPI version

Builds SQL queries from pre-designed JSON structures.

logo

Installation

OS X & Linux & Windows:

pip install jsqlib

Usage example

from jsqlib import Query

json = """{
  "query": {
    "select": [
      {
        "eval": 1
      }
    ]
  }
}
"""

query = Query(json)
assert query.sql == 'select 1'

schema = '{}'
query = Query(json, schema=schema)  # optional schema to validate the query
query.validate()  # explicit query validation

Development setup

  • coverage
poetry run pytest --cov
  • format
poetry run black jsqlib -S
  • lint
poetry run ruff check
  • type checking
poetry run pyre

Release History

  • 0.11a0
    • ADD: postgresql in (values (),...) support (#43)
  • 0.10a0
    • ADD: postgresql pattern matching support (#39)
  • 0.9a0
    • CHANGE: python-box library updated to version 7 (#28)
    • CHANGE: sqlfluff library updated to version 3. Warning: query.prettify output may change. (#34)
    • CHANGE: python 3.12 support (#35)
  • 0.8a0
    • CHANGE: nested select in insert from select statement (#31)
  • 0.7a0
    • ADD: <~~> unquoting wrapper support (#29)
  • 0.6a0
    • CHANGE: validating the rendered json query against the provided schema without any changes (#26)
  • 0.5a0
    • FIX: local variable 'data' referenced before assignment in Builder._update (#18)
    • ADD: support for a name attribute in JSON select definition (#20)
    • ADD: validating JSON query against a schema if any (#19)
  • 0.4a0
    • FIX: order by implicit asc construct (#16)
    • CHANGE: library no longer modifies the original json query (#15)
    • ADD: __version__ package attribute (#14)
  • 0.3a0
    • ADD: not like, delete using constructs (#12, #13)
  • 0.2a0
    • ADD: dialect based stringification (#11)
    • ADD: custom builder support (#10)
  • 0.1a0
    • initial alpha-release
  • 0.0.1
    • wip

Meta

pymancer@gmail.com (Polyanalitika LLC)
https://gitlab.com/ru-r5/jsqlib

License

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.

Contributing

  1. Fork it (https://gitlab.com/ru-r5/jsqlib/fork)
  2. Create your feature branch (git checkout -b feature/foo)
  3. Commit your changes (git commit -am 'Add some foo')
  4. Push to the branch (git push origin feature/foo)
  5. Create a new Pull Request

Project details


Download files

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

Source Distribution

jsqlib-0.11a0.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

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

jsqlib-0.11a0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file jsqlib-0.11a0.tar.gz.

File metadata

  • Download URL: jsqlib-0.11a0.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Linux/5.15.154+

File hashes

Hashes for jsqlib-0.11a0.tar.gz
Algorithm Hash digest
SHA256 a89233ae37c3466bc2c3c8d9b0961fc83ea1fa6b5c9c607214a23ca0213f427d
MD5 9690c932f2d67a713c696a97055e60d8
BLAKE2b-256 bf7fb024b80fbbb86786ba7a2b90914e349c5df7b6a9bf3b0c00233e297d3eda

See more details on using hashes here.

File details

Details for the file jsqlib-0.11a0-py3-none-any.whl.

File metadata

  • Download URL: jsqlib-0.11a0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.13 Linux/5.15.154+

File hashes

Hashes for jsqlib-0.11a0-py3-none-any.whl
Algorithm Hash digest
SHA256 3932304914c725d602cfc951ac41074a0e0057a5852f2d28622734f42d6c2344
MD5 699672766d3b25f1ec76af61e7b9ca69
BLAKE2b-256 a801777e377e0482742546d5a419e5bd80cab0228395b1259c67beeff116a44a

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