How do I check the records of my heroku database?

32,800

Solution 1

You can use heroku run rails console and look at your records with Model.all or any other method.

If you want to backup the database look at heroku PG backups, you then can import your database on your local machine and look at it there. Depending on your db adapter you could use sqlite browser for sqlite3 or phpmyadmin for MySQL.

Solution 2

I found a similar question like this and here is what @Chowlett says:

"You could run heroku pg:psql to fire up a Postgres console, then issue \d to see all tables, and \d tablename to see details for a particular table."

You can also type select * from tablename; to view the table contents.

How to view current database schema for Heroku app in Terminal?

Solution 3

heroku db:pull to pull your production DB locally to take a peek in it.

Solution 4

Heroku now has an add-on named PostgreSQL Studio (currently free & in beta) that would let you access your database from within the browser, without having to use CLI, much like PHP MyAdmin.

To attach this add-on to your application,

heroku addons:create pgstudio

Then go to the list of add-ons on Heroku, select PostgreSQL Studio, authorize it, select the database to connect with from the dropdown list of all databases and it will take you to the web-based interface to handle your selected database.

You may refer to this official article on Heroku: https://devcenter.heroku.com/articles/pgstudio

Solution 5

I'll give the method for connecting via a GUI tool

Run the following command to get the database credentials from Heroku:

heroku pg:credentials DATABASE_URL

Then you can use a GUI tool like PG Commander or PGAdmin to connect to the db

Share:
32,800
Justin Meltzer
Author by

Justin Meltzer

Updated on July 05, 2020

Comments

  • Justin Meltzer
    Justin Meltzer almost 4 years

    I've just deployed my application to heroku and pointed my custom domain to the heroku servers. How can I check the records in my heroku database?

  • Justin Meltzer
    Justin Meltzer about 13 years
    is there anything that can present the records in a more organized way?
  • Andre Schweighofer
    Andre Schweighofer about 13 years
    i added informations about tools to view the database locally. hope this helps!
  • David Rhoden
    David Rhoden about 11 years
    heroku console has been removed.
  • Dennis
    Dennis about 10 years
    Warning: The heroku run command spins up a one-off dyno. Any time spent executing a one-off dyno will contribute to usage and will be charged just like any other dyno if you go over your monthly 750 free dyno-hours.
  • Drenmi
    Drenmi over 8 years
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.
  • Vishal
    Vishal over 8 years
    Thank you. I edited the answer to include the steps.
  • Luke
    Luke almost 7 years
    Works perfectly thanks! Gives: Rows: xxxx/10000
  • Surveyor Jr
    Surveyor Jr about 2 years
    This pgstudio is not available anymore. Any other solution new perhaps? Tried searching the whole Addons and no luck