simonw / sqlite-utils-ask

Ask questions of your data with LLM assistance
Apache License 2.0
27 stars 0 forks source link

Ask files command for querying CSV / JSON etc #10

Closed simonw closed 4 days ago

simonw commented 2 weeks ago

Idea from Datasette Discord. Can use the same mechanism as sqlite-utils memory for turning CSV/TSV/JSON into temporary in-memory tables, the answer a question.

simonw commented 2 weeks ago

Needed this feature in sqlite-utils core first:

simonw commented 2 weeks ago

OK, the prototype works. With a CSV file dogs.csv like this:

name,description
Cleo,Excellent dog
Buffy,Vampire slayer dog

This works:

sqlite-utils ask-files dogs.csv 'count the dogs'
select count(*) from t

[
    {
        "count(*)": 2
    }
]

And:

sqlite-utils ask-files dogs.csv 'count the dogs with slay in their description'
select count(*) from t where description like '%slay%'

[
    {
        "count(*)": 1
    }
]