1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-05 16:18:01 +00:00

Add Open Heroku Database In Postico From Terminal as a Postgres til

This commit is contained in:
jbranchaud
2022-03-04 10:16:55 -06:00
parent 03b0944961
commit 7c0255f49a
2 changed files with 25 additions and 1 deletions

View File

@@ -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)

View File

@@ -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.