Skip to main content

Query JSON using SQL

Project description

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

  • Booleans are cast to integers.
  • Data is assumed to fit in memory.

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

jsonsqlquery-0.1.2.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

jsonsqlquery-0.1.2-py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page