Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Florents-Tselai/liteJQ
jq extension for SQLite.
https://github.com/Florents-Tselai/liteJQ
databases dsl jq json sqlite
Last synced: 9 days ago
JSON representation
jq extension for SQLite.
- Host: GitHub
- URL: https://github.com/Florents-Tselai/liteJQ
- Owner: Florents-Tselai
- License: mit
- Created: 2024-02-22T17:29:42.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-07-08T07:18:36.000Z (4 months ago)
- Last Synced: 2024-10-16T16:20:02.541Z (20 days ago)
- Topics: databases, dsl, jq, json, sqlite
- Language: C
- Homepage: https://tselai.com/litejq.html
- Size: 215 KB
- Stars: 89
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-sqlite - github.com/Florents-Tselai/liteJQ - liteJQ is an SQLite extension, written in C, that brings `jq` support to SQLite using vanilla `jqlib`. (Extensions)
README
# liteJQ: jq support in SQLite
**liteJQ** is an SQLite extension, written in C, that brings `jq` support to SQLite.
It uses vanilla `libjq`.*Note*: If you like the idea, but you're more into Postgres, check out: [pgJQ: jq extension for Postgres](https://github.com/Florents-Tselai/pgJQ)
## Motivation
SQLite has been supporting JSON for years.
Complex queries, however, involving JSON can be more cumbersome to write and understand,
especially when compared to more complex systems like PostgreSQL.
**liteJQ** attempts to alleviate that by bringing the expressive power of jq into SQLite.## Installation
```sh
make
```This produces a `litejq` binary object, which should be loaded in SQLite at runtime.
Verify the installation.
```sh
sqlite3 :memory: < 1980');
```
The above query is equivalent to this one
```sql
select jq(d, '{title: .title, year: .year}')
from movies
where jq(d, '.year') > 1980;
```**Extract Movies with Specific Keywords in Extract**
```sql
select jq(d, '.extract')
from movies
where jq(d, '.extract | contains("silent")');
```**Filter movies by a specific genre (e.g., Drama)**
```sql
select jq(d, '{title: .title, year: .year, genres: .genres}')
from movies
where jq(d, '.genres[] == "Drama"');
```**Filter movies where "Joan Lorring" and "John Dall" played together**
```sql
select jq(d, '{title: .title, year: .year, cast: .cast}')
from movies
where jq(d, '.cast | contains(["Joan Lorring", "John Dall"])');
```**Group by movies by release year**
```sql
select jq(d, '.year'), count(*)
from movies
group by jq(d, '.year')
```## Notes On Installation
For this to work, you'll need development files for both SQLite and jq.
### MacOS
```sh
brew install jq sqlite3
make all
```I've found that `brew` installs header files auomatically for you,
so there's nothing else you have to doVerify installation
```sh
sqlite3 :memory: <