simonw / sqlite-utils-ask

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

Default to markdown output, use `--json` to get JSON #5

Closed simonw closed 3 weeks ago

simonw commented 3 weeks ago

Is Markdown a good default output format? How should the data itself be presented?

I find JSON more readable in the terminal than tables, due to width restraints.

The problem is you really need to be able to see both the SQL and the results, and potentially any commentary as well.

simonw commented 3 weeks ago

Could look like this:

sqlite-utils ask tils.db 'posts per year'
SELECT strftime('%Y', created) AS year, COUNT(*) AS posts_count
FROM til
GROUP BY year

Results:

[
    {
        "year": "2020",
        "posts_count": 100
    },
    {
        "year": "2021",
        "posts_count": 125
    },
    {
        "year": "2022",
        "posts_count": 140
    },
    {
        "year": "2023",
        "posts_count": 117
    },
    {
        "year": "2024",
        "posts_count": 41
    }
]
simonw commented 3 weeks ago

I simplified it to:

SELECT strftime('%Y', created) AS year, COUNT(*) AS posts_count
FROM til
GROUP BY year;

[
    {
        "year": "2020",
        "posts_count": 100
    },
    {
        "year": "2021",
        "posts_count": 125
    },
    {
        "year": "2022",
        "posts_count": 140
    },
    {
        "year": "2023",
        "posts_count": 117
    },
    {
        "year": "2024",
        "posts_count": 41
    }
]