diff --git a/README.md b/README.md index 118bf4d..bd0dc9c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). -_1186 TILs and counting..._ +_1187 TILs and counting..._ --- @@ -616,6 +616,7 @@ _1186 TILs and counting..._ - [List Various Kinds Of Objects](postgres/list-various-kinds-of-objects.md) - [Lower Is Faster Than ilike](postgres/lower-is-faster-than-ilike.md) - [Max Identifier Length Is 63 Bytes](postgres/max-identifier-length-is-63-bytes.md) +- [Open Heroku Database In Postico From Terminal](postgres/open-heroku-database-in-postico-from-terminal.md) - [pg Prefix Is Reserved For System Schemas](postgres/pg-prefix-is-reserved-for-system-schemas.md) - [Prepare, Execute, And Deallocate Statements](postgres/prepare-execute-and-deallocate-statements.md) - [Pretty Print Data Sizes](postgres/pretty-print-data-sizes.md) diff --git a/postgres/open-heroku-database-in-postico-from-terminal.md b/postgres/open-heroku-database-in-postico-from-terminal.md new file mode 100644 index 0000000..73081ae --- /dev/null +++ b/postgres/open-heroku-database-in-postico-from-terminal.md @@ -0,0 +1,23 @@ +# Open Heroku Database In Postico From Terminal + +I recently downloaded [Postico](https://eggerapps.at/postico/) at the +recommendation of [Dillon Hafer](https://dillonhafer.com/). I tend to use +`psql` as a PostgreSQL client for all my database querying needs. However, +Dillon highly recommended Postico for doing system admin querying. + +I needed to connect directly to a production Postgres server on Heroku to +investigate slow queries. Postico presented me with a form of individual fields +for host, port, username, password, database, etc. + +This would have been a little annoying to fill in manually. Dillon had a +shortcut to recommend. From the command line you can open Postico with a +connection string. It knows how to split that connection string into the +respective fields. + +```bash +heroku config:get DATABASE_URL --app APP_NAME | xargs open -a Postico +``` + +This requests the `DATABASE_URL` from Heroku. It is a Postgres connection +string with all the fields needed to connect to a remove server. This is then +passed via `xargs` to `Postico` as it is being `open`ed.