1

When I am developing locally, I'll just run a

rails c

and I can fire of queries at the console.

However, how can I query and access my postgres database that is up on heroku?

1 Answer 1

3

You can run heroku run rails c --app <appname>. I will also add, if you want to view your database, you can make use of PG Commander https://eggerapps.at/pgcommander/ which actually automatically parses all the credentials out for you.

If you want to do this, run heroku config --app <appname> and then copy the DATABASE_URL. After you've done this, create a new favourite in your PG Commander and you'll see that it has already automatically filled in all the credentials based on what was in your clipboard.

Sign up to request clarification or add additional context in comments.

3 Comments

the --app <appname> is optional in case you have multiple apps attached
Thanks! That begs me to ask... if I can do this... why am I not able to run 'heroku run psql databasename' like I can locally?
well you can actually heroku pg:psql as per devcenter.heroku.com/articles/heroku-postgresql

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.