Topic Evaluating CLI interfaces for SQL database access suitable for embedding in a Pi…
- User
Topic
Evaluating CLI interfaces for SQL database access suitable for embedding in a Pi package workflow, comparing Harlequin and usql.
Key Findings
- Harlequin is a TUI/CLI application launched via the
harlequincommand, but has no documented non-interactive or "headless" query mode for scripting (harlequin -c "SELECT ..."); it is oriented toward interactive terminal use [4][7]. - Harlequin uses Click for CLI parsing and dynamically builds options from installed adapters; it supports config profiles (
harlequin --config,harlequin -P "profile") and can be wrapped by application frameworks (e.g.,django-harlequin) [1][4]. usqlis a single-binary, cross-platform universal SQL CLI written in Go, modeled onpsql, supporting Postgres, MySQL, SQLite, SQL Server, Oracle, and others via Godatabase/sqldrivers [1][2][4].usqlis explicitly designed to be scriptable and non-interactive friendly: supports running queries from files (-f), reading from stdin for pipelines, variable interpolation, and result export—making it suitable for embedding in automated workflows [1][4].usqlgenallows creating custom `usql`` builds with additional or alternative database drivers without forking, useful for niche backends [3].
Sources
[1] GitHub - xo/usql: Universal command-line interface for SQL databases — https://github.com/xo/usql [2] Adapters and Config: Multi-database Support in Harlequin — https://harlequin.sh/blog/announcing-adapters-config [3] sclgo/usqlgen: Create custom builds of xo/usql - GitHub — https://github.com/sclgo/usqlgen [4] usql: the universal command-line client for SQL databases - Reddit — https://www.reddit.com/r/commandline/comments/n162oz/usql_the_universal_commandline_client_for_sql/ [7] Harlequin: An innovative tool for managing databases from terminal — https://www.stackscale.com/blog/harlequin-databases-terminal/
Open Questions / Next Steps
- Define how the Pi skill expects to pass queries and consume results (JSON vs plain text, one-off vs persistent sessions) to determine the right integration pattern with .
- Harlequin is a TUI/CLI application launched via the
Assistant
I'll examine the existing skills structure and conventions before shaping up the new skill.
Assistant
Let me study the existing CLI-wrapper skills to match conventions.
Assistant
Let me check the github-cli skill format and verify usql's output-format capabilities (an open question from the research).
Assistant
Let me verify how usql is installed (mise vs go install / release binary) since this package standardizes on mise.
Assistant
I have enough to write the skill. Let me confirm usql's DSN schemes and backslash meta-commands to be accurate.
Assistant
I have everything I need. Now I'll create the
database-queryskill and update the README.Assistant
Let me verify the README skills table rendered correctly.
Assistant
- User
Remove mentions of mise in the skill and also any mention of harlequin. This is purely a skill intended from my Pi workflows to use whenever there is a database query needed
- User
Remove mentions of mise in the skill and also any mention of harlequin. This is purely a skill intended from my Pi workflows to use whenever there is a database query needed
Assistant
Now update the README row to drop the Harlequin mention.
Assistant
Done. Cleaned up the
database-queryskill:- Removed all
misementions — the setup section now just verifies withusql -V/usql -?, and thecompatibilityfrontmatter says "installed and on PATH" without prescribing a manager. - Removed all
Harlequinmentions — dropped the companion callout, the usql-vs-Harlequin table, and the interactive-companion suggestion. The only interactive guidance left is the plainusql "$DATABASE_URL"session drop-in for ad-hoc use. - Updated the README skills-table row to drop the trailing Harlequin sentence.
The skill is now purely a
usql-based database-query skill for your Pi workflows — DSN + query, capture stdout, parse JSON/CSV.- Removed all
- User
Test the skill against this SQLite db /Users/sofianebebert/workspace/dt-platform/diceytech_portfolio.db
Assistant
usqlis installed via mise. Let me put it on PATH and test against the SQLite DB.Assistant
\dtworks (lists tables);\lisn't supported by the SQLite driver — expected, since SQLite is a single-file DB. Let me describe a table and exercise the JSON/CSV/scalar output paths.Assistant
Schema introspection and scalar extraction both work. Now JSON and CSV output, plus a
jqpipeline and a-ffile query.Assistant
JSON and CSV both work. Now the
-ffile, stdin, and variable-interpolation paths.Assistant
All scripted paths work against this real SQLite DB:
\dt,\d, scalar capture (-q -t), JSON (-J+jq), CSV (-C),-ffile (multi-statement), stdin pipe, and variable interpolation (-v).One real finding from the test:
\lis not supported by the SQLite driver — meta-command availability is driver-dependent, not universal. The skill currently implies they all work with-c. Let me fix that so the skill is accurate for cross-backend use.Assistant
Test results — skill verified against
diceytech_portfolio.dbI exercised every workflow pattern the skill documents against the real SQLite DB (usql 0.21.4, installed via mise — I added it to PATH for the session since it wasn't on PATH globally):
Pattern Command shape Result List tables usql DSN -c "\dt" -q✅ 20 tables listed Describe table usql DSN -c "\d users" -q✅ 45 columns with types/nullability - User
Perfect, commit and push our changes
Assistant
Committed and pushed.
- Commit
6fb98d9— "Add database-query skill for non-interactive SQL via usql" (2 files: newskills/database-query/SKILL.md+ README skills-table row) - Pushed
main→origin/main(also carried the 1 commit that was already ahead).
Both the
database-queryskill and the README update are now on the remote.- Commit