Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: sql module. #160

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

feat: sql module. #160

wants to merge 2 commits into from

Conversation

igalklebanov
Copy link
Member

@igalklebanov igalklebanov commented Feb 16, 2025

Hey 👋

This PR allows running SQL queries in the terminal, connecting to your database via the configured Kysely instance.

This was born out of wanting to query the database in between migrations in CI, might as well make it publicly available in the CLI.

It works in single query mode where you pass the SQL string as a positional argument:

kysely sql "select * from moshe"
════════════════                                                                                                                                                                    
 id    is_moshe 
 null         1 
 null         1 
 null         1 
 null         1 
 null         1 
 12           0 
 13           1 
════════════════

Or prompt mode:

kysely sql

✔ sqlite ❯
select 1
═══                                                                                                                                                                                 
 1 
 1 
═══


❯ sqlite ❯
exit

It supports 3 types of formats: table (default), csv and json.
It supports multi-line queries in prompt mode - just end your lines with \.

@igalklebanov igalklebanov added the enhancement New feature or request label Feb 16, 2025
Copy link

pkg-pr-new bot commented Feb 16, 2025

Open in Stackblitznode-esm

npm i https://pkg.pr.new/kysely-org/kysely-ctl@160

commit: d4a776d

@igalklebanov igalklebanov changed the title feat: sql prompt. feat: sql module. Feb 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant