Skip to content

Peter554/jsonsqlquery

Repository files navigation

jsonsqlquery

CI

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

  • Data is cast to SQLite data types.
  • Data is assumed to fit in memory.

About

Query JSON with SQL

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published