j q u e
Query JSON in memory as though it were a Mongo database
Installation
pip3 install jque
Usage
import jque
jque accepts a variety of inputs to the constructor.
Pass a list of dicts:
data = jque.jque([
{ "name": "john" },
{ "name": "paul" },
{ "name": "george" },
{ "name": "ringo" }
])
Pass a JSON filename:
DATAFILE = "~/my/big/data.json"
data = jque.jque(DATAFILE)
Now you can query this dataset using Mongo-like syntax:
>>> data.query({ "name": {"$neq": "paul"} })
[
{ "name": "john" },
{ "name": "george" },
{ "name": "ringo" }
]
Arguments to query:
| Arg | Description |
|---|---|
wrap (boolean : True) |
Whether to wrap the resultant dataset in a new jque object. This allows chaining, like jque.query(...).query(...), if you're the sort of person to do that. Pass False to get back a list instead. |
Another example!
data = jque.jque([{
"_id": "ABC",
"name": "Arthur Dent",
"age": 42,
"current_planet": "earth"
}, {
"_id": "DE2",
"name": "Penny Lane",
"age": 19,
"current_planet": "earth"
}, {
"_id": "123",
"name": "Ford Prefect",
"age": 240,
"current_planet": "Brontitall"
}])
teenage_earthlings = data.query({
"current_planet": {"$eq": "earth"},
"age": { "$lte": 20, "$gte": 10 }
})
Which returns:
[{
"_id": "DE2",
"name": "Penny Lane",
"age": 19,
"current_planet": "earth"
}]
Use Python lambdas as a filter:
>>> libraries = jque.jque([
... {"name": "jque", "language": "Python"},
... {"name": "react", "language": "node"}
... ])
>>> list(libraries.query({
... 'language': lambda x: x[:2] == "Py"
... }))
[{"name": "jque", "language": "Python"}]
Metadata
Release files for jque 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jque-0.1.3.tar.gz | 4.6 kB | Without provenance | Details for jque-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jque-0.1.3-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for jque-0.1.3-py2.py3-none-any.whl |
Total release size: 8.5 kB
Release files / jque-0.1.3.tar.gz
| Download URL | jque-0.1.3.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b228a4fd2d3a983418e372a2c20ef369b3140c7206ba892f94c7c5dcea38349
|
|
BLAKE2b-256 checksum How to use checksums |
3dc74d37639c2b34efdd077dc1f9f2886d370a1bfb51888b7955ce61e7e27852
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|
Release files / jque-0.1.3-py2.py3-none-any.whl
| Download URL | jque-0.1.3-py2.py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
0497c51c9a0174ee742493301dc604ce2147cb7c9f705bcbaefc0dd6ca2b0ec0
|
|
BLAKE2b-256 checksum How to use checksums |
4eaf9d7c1e438a3e3cee3b2fc5c5e54e02ecc24f3acf77889030aee303ef5ede
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|
Security for jque 0.1.3
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.