mdq queries multiple databases in parallel and output the results in JSON.
$ mysql -u root --database example -e "select * from hello";
+------+---------+
| id | message |
+------+---------+
| 1 | hello |
| 2 | world |
+------+---------+
$ cat ~/.config/mdq/config.yaml
dbs:
- name: "example_db"
driver: "mysql"
dsn: "root@/example"
tags: ["example_tag"]
$ mdq --tag example_tag "select * from hello" | jq .
[
{
"Database": "example_db",
"Columns": [
"id",
"message"
],
"Rows": [
{
"id": "1",
"message": "hello"
},
{
"id": "2",
"message": "world"
}
]
}
]
- MySQL
[username[:password]@][protocol[(address)]]/dbname[?param1=value1&...¶mN=valueN]
- github.com/go-sql-driver/mysql
- PostgreSQL
host=host dbname=dbname user=user password=password ssl=require
- github.com/lib/pq