One of the things making your Heroku hosted database, certainly from a remote box, or a console difficult is the need to get an application running with the Heroku gems. This means also means your system admin team needs to be concerned with Gems too. Here are the steps to gain access to your Heroku data base with a psql console to execute commands.
1) We do need application access and the gem to do this.
➜ words git:(master) heroku config === words Config Vars AWS_KEY: keys AWS_SECRET: secrets DATABASE_URL: postgres://foo:baz@ec2-34-34-34.compute-1.amazonaws.com:5432/foochickenheads HEROKU_POSTGRESQL_GREEN_URL: postgres://foo:baz@ec2-34-34-34.compute-1.amazonaws.com:5432/foochickenheads
The line of interest is the DATABASE_URL
2) Now construct a request like this.
$ psql "user=foo password=baz host=ec2-34-34-34.compute-1.amazonaws.com port=5432 dbname=foochickenheads sslmode=require" foochickenheads=>
With this setup you can access many of the postgres programs you may need not currently supported by heroku pg:commands.
3) We can also use this setup to gain Postgres access with commands not available through $ heroku pg. This next example looks at pg_dump.
$ pg_dump -f 'users' "user=foo password=baz host=ec2-34-34-34.compute-1.amazonaws.com port=5432 dbname=foochickenheads sslmode=require" > ~/dumps/users.sql
:)