Command line tool to perform SQL database queries. With sqline you can mix the power of Unix tools with the power of SQL.
To install sqline, simply:
pip install sqlineYou need to set the following environment variables:
DB_USERDB_PASSWORDDB_ENDPOINTDB_NAMEDB_PORTDB_DIALECT: Engine and driver for SQLAlchemy.
Making a simple query is easy as running sqline "select * from users limit 10". One you're happy with your query you can get the entire result in JSON or CSV. Is also possible to get the input from a file. For example, having query.sql:
SELECT
user,
age,
country
FROM users
WHERE age > 25Running cat query.sql | sqline -o json will give a set of new line delimited JSONs. You can plug any existing Unix tool to the output, for example jq for the JSON output (cat query.sql | sqline -o json | jq .country | uniq -c).
Contributions are welcome!