« BackSq.io: jq for databases and moresq.ioSubmitted by stavepan 2 hours ago
  • jasongill 5 minutes ago

    This is interesting. I wonder if there is anything that does the opposite - takes JSON input and allows you to query it with SQL syntax (which would be more appealing to an old-timer like me)

    • candiddevmike 2 hours ago

      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.

      • varenc 21 minutes ago

        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.

        • maxfurman 17 minutes ago

          You may know this already, but the SQLite CLI can actually read and query data directly from a csv file, with the right flags

      • wreq2luz 14 minutes ago

        I was reading about something like json output coming to Postgres one day (https://www.postgresql.org/message-id/flat/ZYBdnGW0gKxXL5I_@...). Also the `.wrangle | .data` wraps on an iPhone 13 mini.

        • doctorpangloss an hour ago

          At some point, why not package Python into a single executable, and symbolic link applications and modules into it for Unixy-ness?

          Another POV is all the developers I know who thrive the most and have found the most success: they rate aesthetic concerns the lowest when looking at their tools. That is to say that the packaging or aesthetic coherence in some broader philosophy matters less than other factors.

          • sweeter 36 minutes ago

            Its written in Go...

          • varenc an hour ago

            I love sq. It's handy for quickly performing simple operations on DBs and outputting that as CSV or JSON. Though my one wish is that the sq query language (SLQ) supported substring matching like SQL's `... LIKE "SOME_STRING%"`. Though you can just invoke SQL manually with `sq sql`

            • rout39574 an hour ago

              I love JQ. But ... I'd never considered its query language to be particularly admirable. If I want to ask questions of some databases, I don't understand why I'd choose JQ's XPATH-like language to do it.

              • hvenev 38 minutes ago

                The demo appears too stateful for me. The real power of `jq` is its reliability and the ability to reason about its behavior, which stateful tools inherently lack.

                • robertclaus 2 hours ago

                  More tools are always great! Even if it doesn't become the mainstream, it's always great to see people explore new ways of dealing with databases!

                  • prepend an hour ago

                    More good tools are always great. But I don’t think random clutter is always good.

                    Fortunately we don’t have to see it so it’s not like it blocks my vision.

                    But I just wanted to note that the idea of “anything is good” is not really true and I don’t like its spread as there’s opportunity cost. I think we need to spend more attention on evaluation and quality and making good things than the idea that even creating lots of bad things is good in some way.

                  • cassepipe 18 minutes ago

                    Not to be confused with the gpg alternative from sequoia-pgp also called sq : https://sequoia-pgp.org/

                    • mlhpdx 2 hours ago

                      Dang, I wish I had this while I still had SQL databases.

                      • tgmatt an hour ago

                        Sorry but I am pronouncing that as 'ess-cue` and there is nothing anyone can do about it.

                        Looks kinda neat for when I don't want or need anything more than bash for a script.

                        • fforflo 2 hours ago

                          I love the idea of pushing JQ and other DSLs close to the database. I've written jq extensions for SQLite [0] and Postgres [1], but my approach involves basically embedding=pushing the jq compiler into the db. So you can do `select jq(json, jqprogram)` as an alternative to jsonpath.

                          Trying to understand: Is the main purpose of this to use jq-syntax for cataloging-like functionality and/or cross-query? I mean it's quite a few lines of code, but you inspect the database catalogs and offer a layer on top of that? I mean, how much data is actually leaving the database?

                          [0] https://github.com/Florents-Tselai/liteJQ [1] https://github.com/Florents-Tselai/pgJQ

                          • renewiltord 2 hours ago

                            Related is Google’s pipe syntax for SQL https://research.google/pubs/sql-has-problems-we-can-fix-the...