Skip to content

A minimal terminal-based sql querier that uses sqlc-compatible files

License

Notifications You must be signed in to change notification settings

gustapinto/sqlk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQLK

A minimal terminal-based sql querier that uses sqlc-compatible files.

This project does not aims to be a full DBA tool, like DBeaver or Jetbraind Datagrip, instead we provide only a simple command line based tool to execute queries and return its results in plain-text open formats, like JSON.

The SQLK outputs are intended to be as plain and simple as possible, in order to be parsed by external tools, like jq and miller.

Usage

sqlk -conn connection_name -file file.sql -query namedquery

The query file format

SQLK uses the same .sql file format as sqlc.

And example query file, named foo.sql:

-- name: SelectNumber :one
SELECT 1 AS "NUMBER";

To execute the SelectNumber query we can execute SQLK as:

sqlk -file foo.sql -query selectnumber

This call would return the following:

{"NUMBER":1}

Configuration

SQLK uses a json based configuration for its connection settings, the default configuration file can be found at $HOME/.sqlk.json, but other files can be passed using the -config file.path.json flag.

An example configuration file:

{
    "connections": [
        {
            "name": "conn",
            "driver": "postgres",
            "dsn": "postgres://conn:conn@localhost:5432/database_name?sslmode=disable",
            "default": true
        }
    ]
}

About

A minimal terminal-based sql querier that uses sqlc-compatible files

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages