All Projects → marianogappa → Sql

marianogappa / Sql

Licence: mit
MySQL & PostgreSQL pipe

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Sql

Octosql
OctoSQL is a query tool that allows you to join, analyse and transform data from multiple databases and file formats using SQL.
Stars: ✭ 2,579 (+3083.95%)
Mutual labels:  cli, sql, mysql, postgresql
Sql Lint
An SQL linter
Stars: ✭ 243 (+200%)
Mutual labels:  sql, mysql, postgresql, postgres
Electrocrud
Database CRUD Application Built on Electron | MySQL, Postgres, SQLite
Stars: ✭ 1,267 (+1464.2%)
Mutual labels:  sql, mysql, postgresql, postgres
Trdsql
CLI tool that can execute SQL queries on CSV, LTSV, JSON and TBLN. Can output to various formats.
Stars: ✭ 593 (+632.1%)
Mutual labels:  cli, sql, mysql, postgresql
Goqu
SQL builder and query library for golang
Stars: ✭ 984 (+1114.81%)
Mutual labels:  sql, mysql, postgresql, postgres
Sequelize Auto Migrations
Migration generator && runner for sequelize
Stars: ✭ 233 (+187.65%)
Mutual labels:  cli, sql, mysql, postgresql
Sqliterally
Lightweight SQL query builder
Stars: ✭ 231 (+185.19%)
Mutual labels:  sql, mysql, postgresql, postgres
Jet
Type safe SQL builder with code generation and automatic query result data mapping
Stars: ✭ 373 (+360.49%)
Mutual labels:  sql, mysql, postgresql, postgres
Sqlx
🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, SQLite, and MSSQL.
Stars: ✭ 5,039 (+6120.99%)
Mutual labels:  sql, mysql, postgresql, postgres
Vscode Sqltools
Database management for VSCode
Stars: ✭ 741 (+814.81%)
Mutual labels:  sql, mysql, postgresql, postgres
Xorm
Simple and Powerful ORM for Go, support mysql,postgres,tidb,sqlite3,mssql,oracle, Moved to https://gitea.com/xorm/xorm
Stars: ✭ 6,464 (+7880.25%)
Mutual labels:  mysql, postgresql, postgres
Smartsql
SmartSql = MyBatis in C# + .NET Core+ Cache(Memory | Redis) + R/W Splitting + PropertyChangedTrack +Dynamic Repository + InvokeSync + Diagnostics
Stars: ✭ 775 (+856.79%)
Mutual labels:  sql, mysql, postgresql
Eralchemy
Entity Relation Diagrams generation tool
Stars: ✭ 767 (+846.91%)
Mutual labels:  sql, mysql, postgresql
Usql
Universal command-line interface for SQL databases
Stars: ✭ 6,869 (+8380.25%)
Mutual labels:  sql, mysql, postgresql
Schemats
Generate typescript interface definitions from SQL database schema
Stars: ✭ 799 (+886.42%)
Mutual labels:  mysql, postgresql, postgres
Fluentpdo
A PHP SQL query builder using PDO
Stars: ✭ 783 (+866.67%)
Mutual labels:  sql, mysql, postgresql
Ebean
Ebean ORM
Stars: ✭ 1,172 (+1346.91%)
Mutual labels:  sql, mysql, postgres
Node Pg Migrate
Node.js database migration management for Postgresql
Stars: ✭ 838 (+934.57%)
Mutual labels:  sql, postgresql, postgres
Monogamy
Add table-level database locking to ActiveRecord
Stars: ✭ 12 (-85.19%)
Mutual labels:  mysql, postgresql, postgres
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 7,712 (+9420.99%)
Mutual labels:  sql, mysql, postgres

sql Build Status GitHub license

MySQL pipe

SQL

Blogpost

What does it do?

  • sql allows you to pipe STDIN (hopefully containing SQL) to one or more pre-configured MySQL or PostgreSQL databases
  • output comes out in \t-separated format, allowing further piping (e.g. works really well with chart)
  • when more than one database is queried, the requests are made in parallel
  • sql can either run mysql/psql locally, run mysql/psql locally but connecting to a remote host (by configuring a dbServer), or ssh to a remote host and from there run mysql/psql to either a local or remote host (by configuring an appServer and a dbServer)

Installation

Get the latest binary on the Releases section, or via go get:

go get -u github.com/marianogappa/sql

Auto completion

Optionaly, you can install auto complete scripts for your shell too. It will complete the name of databases.

For bash, copy or link sql-bash-autocomplete file to /etc/bash_completion.d directory.

For zsh, copy or link sql-zsh-autocomplete file to somewhere in your $fpath. (If you use oh-my-zsh framework, copy/link it to ~/.oh-my-zsh/completions.) Note that file should be renamed to _sql. You may also need to run the following commands in order to force ZSH to rebuild its auto completion cache.

$ rm ~/.zcompdump
$ compinit

Configuration

Create a .databases.json dotfile in your home folder or in any XDG-compliant directory. This is an example file.

sql decides to execute with MySQL or PostgreSQL depending on the sqlType property set for a database, defaulting to to MySQL if not set.

Example usages

cat query.sql | sql test_db

sed 's/2015/2016/g' query_for_2015.sql | sql db1 db2 db3

sql all "SELECT * FROM users WHERE name = 'John'"

Notes

  • when more than one database is queried, the resulting rows are prefixed with the database identifier
  • the all special keyword means "sql to all configured databases".
  • sql assumes that you have correctly configured SSH keys on all servers you ssh to
  • sql will error if all targeted databases do not have the same sql type.

Beware!

  • please note that ~/.databases.json will contain your database credentials in plain text; if this is a problem for you, don't use sql!
  • sql is meant for automation of one-time lightweight ad-hoc SELECTs on many databases at once; it's not recommended for mission critical bash scripts that do destructive operations on production servers!
  • If you close an ongoing sql operation, spawned mysql and ssh->mysql processes will soon follow to their deaths, but the underlying mysql server query thread will complete, as long as it takes! https://github.com/marianogappa/sql/issues/7

Dependencies

  • mysql-client and/or postgresql-client
  • ssh (only if you configure an "appServer")

Contribute

If you have an issue with sql, I'd love to hear about it. PRs are welcome. Ping me on Twitter if you want to have a chat about it.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].