Query JSON using SQL
Project description
jsonsqlquery
Query JSON using SQL.
pip install jsonsqlquery
Examples
# students.jsonl
{"name": "Alvin", "age": 25, "major": "Literature"}
{"name": "Kathy", "age": 31, "major": "Literature"}
{"name": "Pauline", "age": 11, "major": "Mathematics"}
{"name": "Nora", "age": 27, "major": "Mathematics"}
{"name": "Martin", "age": 54, "major": "Geology"}
Inline SQL query:
cat students.jsonl | jsonsqlquery --query 'select name, age from data where age > 30'
SQL query from a file:
cat students.jsonl | jsonsqlquery --query-file query.sql
Create a SQLite database:
cat students.jsonl | jsonsqlquery --create-db students.db
Python API:
import jsonsqlquery
students = [...]
older_students = jsonsqlquery.query(students, "select name, age from data where age > 30")
Caveats
- Booleans are cast to integers.
- Data is assumed to fit in memory.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jsonsqlquery-0.1.2.tar.gz
(3.1 kB
view hashes)
Built Distribution
Close
Hashes for jsonsqlquery-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f3dda19d66eb4922024b4decb652534a530cda9298fe737d8db74d4cb3a0ac1 |
|
MD5 | ded4e91a7fd6d81cc9c7f9fdd732e2bf |
|
BLAKE2b-256 | 40de150db61d4ad16dad5fd6533952addca2547645de8b76fdcd9aa7cef40222 |