# jsqlib
> JSON to SQL query generator.
[![pipeline status](https://gitlab.com/ru-r5/jsqlib/badges/master/pipeline.svg)](https://gitlab.com/ru-r5/jsqlib/-/commits/master)
[![PyPI version](https://badge.fury.io/py/jsqlib.png)](https://badge.fury.io/py/jsqlib)
Builds SQL queries from pre-designed JSON structures.
![](jsqlib.png)
## Installation
OS X & Linux & Windows:
```sh
pip install jsqlib
```
## Usage example
```python
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
```sh
$ poetry run pytest --cov
```
- format
```sh
$ poetry run black jsqlib -S
```
- lint
```sh
$ poetry run ruff check
```
- type checking
```sh
$ poetry run pyre
```
## Release History
- 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://polyanalitika.ru))
[https://gitlab.com/ru-r5/jsqlib](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
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/ru-r5/jsqlib",
"name": "jsqlib",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.13,>=3.9",
"maintainer_email": null,
"keywords": "sql, json",
"author": "pymancer",
"author_email": "pymancer@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ca/b5/ee555ecdcba3c12c813d69b8ab974d24cbb5dfd286d2b4b8ce7b5d0f5a79/jsqlib-0.9a0.tar.gz",
"platform": null,
"description": "# jsqlib\n> JSON to SQL query generator.\n\n[![pipeline status](https://gitlab.com/ru-r5/jsqlib/badges/master/pipeline.svg)](https://gitlab.com/ru-r5/jsqlib/-/commits/master)\n[![PyPI version](https://badge.fury.io/py/jsqlib.png)](https://badge.fury.io/py/jsqlib)\n\nBuilds SQL queries from pre-designed JSON structures.\n\n![](jsqlib.png)\n\n## Installation\n\nOS X & Linux & Windows:\n\n```sh\npip install jsqlib\n```\n\n## Usage example\n\n```python\nfrom jsqlib import Query\n\njson = \"\"\"{\n \"query\": {\n \"select\": [\n {\n \"eval\": 1\n }\n ]\n }\n}\n\"\"\"\n\nquery = Query(json)\nassert query.sql == 'select 1'\n\nschema = '{}'\nquery = Query(json, schema=schema) # optional schema to validate the query\nquery.validate() # explicit query validation\n```\n\n## Development setup\n- coverage\n\n```sh\n$ poetry run pytest --cov\n```\n\n- format\n\n```sh\n$ poetry run black jsqlib -S\n```\n\n- lint\n\n```sh\n$ poetry run ruff check\n```\n\n- type checking\n\n```sh\n$ poetry run pyre\n```\n\n## Release History\n- 0.9a0\n - CHANGE: python-box library updated to version 7 (#28)\n - CHANGE: sqlfluff library updated to version 3. Warning: query.prettify output may change. (#34)\n - CHANGE: python 3.12 support (#35)\n- 0.8a0\n - CHANGE: nested `select` in `insert from select` statement (#31)\n- 0.7a0\n - ADD: `<~~>` unquoting wrapper support (#29)\n- 0.6a0\n - CHANGE: validating the rendered json query against the provided schema without any changes (#26)\n- 0.5a0\n - FIX: local variable 'data' referenced before assignment in Builder._update (#18)\n - ADD: support for a `name` attribute in JSON `select` definition (#20)\n - ADD: validating JSON query against a schema if any (#19)\n- 0.4a0\n - FIX: `order by` implicit `asc` construct (#16)\n - CHANGE: library no longer modifies the original json query (#15)\n - ADD: `__version__` package attribute (#14)\n- 0.3a0\n - ADD: `not like`, `delete` `using` constructs (#12, #13)\n- 0.2a0\n - ADD: dialect based stringification (#11)\n - ADD: custom builder support (#10)\n- 0.1a0\n - initial alpha-release\n- 0.0.1\n - wip\n\n## Meta\n\npymancer@gmail.com ([Polyanalitika LLC](https://polyanalitika.ru)) \n[https://gitlab.com/ru-r5/jsqlib](https://gitlab.com/ru-r5/jsqlib)\n\n## License\n\nThis Source Code Form is subject to the terms of the Mozilla Public \nLicense, v. 2.0. If a copy of the MPL was not distributed with this \nfile, You can obtain one at https://mozilla.org/MPL/2.0/. \n\n## Contributing\n\n1. Fork it (<https://gitlab.com/ru-r5/jsqlib/fork>)\n2. Create your feature branch (`git checkout -b feature/foo`)\n3. Commit your changes (`git commit -am 'Add some foo'`)\n4. Push to the branch (`git push origin feature/foo`)\n5. Create a new Pull Request\n",
"bugtrack_url": null,
"license": "MPL-2.0",
"summary": "JSON to SQL query generator",
"version": "0.9a0",
"project_urls": {
"Documentation": "https://gitlab.com/ru-r5/jsqlib/-/wikis/home",
"Homepage": "https://gitlab.com/ru-r5/jsqlib",
"Repository": "https://gitlab.com/ru-r5/jsqlib"
},
"split_keywords": [
"sql",
" json"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "23c4c6b3223e9ba245cdeaece2170b05cdca824757f1249dd96992162f7ad4e0",
"md5": "27adec3ce301ad94545adba7b5855628",
"sha256": "f2f5242cbe6d93aa06e9df78f3bec68b47eee7f1979baa8f989fa587229bf471"
},
"downloads": -1,
"filename": "jsqlib-0.9a0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "27adec3ce301ad94545adba7b5855628",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.13,>=3.9",
"size": 12563,
"upload_time": "2024-08-07T17:12:22",
"upload_time_iso_8601": "2024-08-07T17:12:22.503945Z",
"url": "https://files.pythonhosted.org/packages/23/c4/c6b3223e9ba245cdeaece2170b05cdca824757f1249dd96992162f7ad4e0/jsqlib-0.9a0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cab5ee555ecdcba3c12c813d69b8ab974d24cbb5dfd286d2b4b8ce7b5d0f5a79",
"md5": "c678b04956b392c881edcfcbe5cd8786",
"sha256": "668dabf511151da938ff5e850b7a1d193165f4fd6d420838516da4e5a802a7fd"
},
"downloads": -1,
"filename": "jsqlib-0.9a0.tar.gz",
"has_sig": false,
"md5_digest": "c678b04956b392c881edcfcbe5cd8786",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.13,>=3.9",
"size": 11167,
"upload_time": "2024-08-07T17:12:23",
"upload_time_iso_8601": "2024-08-07T17:12:23.840476Z",
"url": "https://files.pythonhosted.org/packages/ca/b5/ee555ecdcba3c12c813d69b8ab974d24cbb5dfd286d2b4b8ce7b5d0f5a79/jsqlib-0.9a0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-07 17:12:23",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "ru-r5",
"gitlab_project": "jsqlib",
"lcname": "jsqlib"
}