Skip to main content

A JSON query to SQL parser loosely based on the Loopback Query Language

Project description

# JTOS

JSON to SQL. Inspired by the Loopback Query Language, this is a standalone Python library to convert JSON objects to SQL.

## Schema

### Select
```json
{
"select": {
"tables": [],
"fields": []
}
}
```
### Joins
```json
{
"join": {
"type": "LEFT | RIGHT etc",
"conditions":{
"from": {
"table": "",
"field": ""
},
"to": {
"table": "",
"field": ""
}
}
}
}
```

### Where Conditions
```json
{
"where": [
{
"field": "",
"op": <op>,
"val": "",
"join": "o|a"
}
]
}
```

NOTE: An operator should only be included from the second index and it will be prepended to the built string

### Ordering
```json
{
"select":{
...,
"orderBy": {
"<field>": "ASC|DESC"
}
}
}
```
### Grouping
```json
{
"select":{
...,
"groupBy": [
"<field>"
]
}
}
```
### Paging
```json
{
"limit": 100,
"offset": 3
}
```
### Insert
```json
{
"insert": {
"table": "",
"values": {
"<field>": "<value>"
}
}
}
```


## Operations

* gt - >
* lt - <
* gte - >=
* lte - <=
* e - =
* ne - !=
* l - LIKE
* nl - NOT LIKE
* a - AND
* a - OR

---

## Notes

This does **no** authentication or validation,
it just blindly trusts the tests.

Do not run on production unless you are comfortable with it in your test environment first

## Contributing

Tests, please! But also any work on Upserts or Delete are also greatly appreciated

## TODO

* [X] Select
* [X] Where
* [X] Joins
* [X] Insert
* [ ] Upsert (this syntax is quite different so maybe needs a different parser)
* [X] Delete


## Examples

Examples are included in the `tests` directory

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

JTOS-0.8.3.tar.gz (4.2 kB view details)

Uploaded Source

File details

Details for the file JTOS-0.8.3.tar.gz.

File metadata

  • Download URL: JTOS-0.8.3.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for JTOS-0.8.3.tar.gz
Algorithm Hash digest
SHA256 6618ed427c7ec13d48ad21bc1c0ef7e0b467d5ad358d1669fbeab607c72964ed
MD5 84c4cb745338460ca1a36cbb8a055325
BLAKE2b-256 984b605c560f4d1af826d413c9a266191d741f87de534b115c1a4d3d1efe26be

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