开发者

How do I check the records of my heroku database?

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?


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.


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?


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


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


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


The easy answer is:

heroku pg:info


You can also download a client side Postgres, like Postico, and using the information provided in that URL to enter password and database name etc, then you can create locally, just like phpMyAdmin.


I use the admin_data gem, works well in Heroku.


You can use heroku dataclips that allows to run queries online. Here you can find documentation https://devcenter.heroku.com/articles/dataclips.


Connect to the database using Sequel Pro. You can find your ClearDB url using heroku config command. The structure for connecting is as follows:

CLEARDB_DATABASE_URL => mysql://[username]:[password]@[host]/[database name]?reconnect=true
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜