Skip to content

Instantly share code, notes, and snippets.

@sletix
Created August 18, 2017 18:56
Show Gist options
  • Save sletix/556bdf3631de5fa01e3676e7f110516e to your computer and use it in GitHub Desktop.
Save sletix/556bdf3631de5fa01e3676e7f110516e to your computer and use it in GitHub Desktop.
sql2slack
#!/bin/bash
## settings: ----
# db
host="localhost"
db="dbname"
user="sletix"
password=""
# slack hook
slack_webhook="https://hooks.slack.com/services/XXXXXXX/XXXXXXX/YYYYYyyyyYYYYYyyyyYY"
title="Sample Query"
result=$(psql postgresql://$user:$password@$host/$db << EOF
/* Write your query here: */
EOF)
curl -X POST --data "{\"text\":\":alien:[$title]\n$result\"}" $slack_webhook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment