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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file jsonsqlquery-0.1.2.tar.gz.

File metadata

  • Download URL: jsonsqlquery-0.1.2.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.10.6 Darwin/22.3.0

File hashes

Hashes for jsonsqlquery-0.1.2.tar.gz
Algorithm Hash digest
SHA256 dfa366b95ba87a00d49ace1066761d97a43fedab6026dc3ea3d6b954ec47feef
MD5 1a5d10fac6fa4786abaea202ea85b84e
BLAKE2b-256 79733382dce1403d2d4cbec01b84473ed90bdcfabdb13523dbb1852bc6434860

See more details on using hashes here.

File details

Details for the file jsonsqlquery-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: jsonsqlquery-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.10.6 Darwin/22.3.0

File hashes

Hashes for jsonsqlquery-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9f3dda19d66eb4922024b4decb652534a530cda9298fe737d8db74d4cb3a0ac1
MD5 ded4e91a7fd6d81cc9c7f9fdd732e2bf
BLAKE2b-256 40de150db61d4ad16dad5fd6533952addca2547645de8b76fdcd9aa7cef40222

See more details on using hashes here.

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