News for hackers. Stuff that matters.
Re:Sq.io: jq for databases and more by candiddevmike on Sunday October 06, 2024 @06:39PM (#41760955)
This is neat but I'm not really seeing anything I can't do with standard SQL and CLI tools like psql. Seems like you'd learn more reusable things using standard SQL too.
Re:Sq.io: jq for databases and more by varenc on Sunday October 06, 2024 @07:58PM (#41761448)
I find sq handy when you use it to accomplish things you can't (easily) do with just raw SQL. Things like: exporting certain rows to JSON or CSV, transforming rows into nicely formatted log lines for viewing, or reading in a CSV file and querying it the same way you'd query other databases. It's particularly easy to start using if you're already familiar with the jq.

If you use things like `array_to_json(array_agg(row_to_json(....)))` in your psql commands to output some rows to JSON, then sq's `--json` or `--jsonl` is quite a bit easier IMHO. If you know the exact SQL query you want to run you can just do `sq sql '....'` as well, but I agree there's not much point in doing that if you aren't taking advantage of some other sq feature.

Re:Sq.io: jq for databases and more by maxfurman on Sunday October 06, 2024 @08:02PM (#41761470)
You may know this already, but the SQLite CLI can actually read and query data directly from a csv file, with the right flags
Re:Sq.io: jq for databases and more by ec109685 on Monday October 07, 2024 @02:12AM (#41763225)
They are Jedi’s at jq though.
Re:Sq.io: jq for databases and more by aurareturn on Monday October 07, 2024 @01:33AM (#41763076)
I agree with @candiddevmike. Might I add that you can do those things fairly easily now with ChatGPT/Claude. I doubt LLMs know how to use Sq.io that much.
Re:Sq.io: jq for databases and more by neilotoole on Monday October 07, 2024 @10:44AM (#41766511)
> I'm not really seeing anything I can't do with standard SQL and CLI tools like psql.

Developer here. There's a few features other than the query stuff that I still think are pretty handy.

The "sq inspect" stuff isn't easy to do with the standard CLI tools, or at least wasn't when I started working on sq back in 2013 or so.

https://sq.io/docs/inspect

I also regularly make use of the ability to diff the metadata/schema of different DB instances (e.g. "sq diff @pg_prod @pg_qa").

https://sq.io/docs/diff