Ruby-on-rails 如何查看我的 heroku 数据库的记录?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5825424/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 01:02:05  来源:igfitidea点击:

How do I check the records of my heroku database?

ruby-on-railsrubydatabasehostingheroku

提问by Justin Meltzer

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?

我刚刚将我的应用程序部署到 heroku 并将我的自定义域指向了 heroku 服务器。如何检查我的 heroku 数据库中的记录?

回答by Andre Schweighofer

You can use heroku run rails consoleand look at your records with Model.allor any other method.

您可以使用或任何其他方法使用heroku run rails console和查看您的记录Model.all

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 browserfor sqlite3 or phpmyadminfor MySQL.

如果要备份数据库,请查看heroku PG backups,然后可以在本地计算机上导入数据库并在那里查看。根据您的数据库适配器,您可以将sqlite 浏览器用于 sqlite3 或phpmyadmin用于 MySQL。

回答by Daniel

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

我发现了一个类似的问题,这是@Chowlett 所说的:

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

“您可以运行heroku pg:psql以启动 Postgres 控制台,然后发出\d以查看所有表,并\d tablename查看特定表的详细信息。”

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

您还可以键入select * from tablename;以查看表格内容。

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

如何在终端中查看 Heroku 应用程序的当前数据库架构?

回答by John Beynon

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

heroku db:pull 将您的生产数据库拉到本地以查看它。

回答by hexinpeter

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

我将给出通过GUI工具连接的方法

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

运行以下命令从 Heroku 获取数据库凭据:

heroku pg:credentials DATABASE_URL

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

然后你可以使用像 PG Commander 或 PGAdmin 这样的 GUI 工具连接到数据库

回答by Vishal

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.

Heroku 现在有一个名为 PostgreSQL Studio 的附加组件(目前免费且处于测试阶段),它可以让您从浏览器中访问您的数据库,而无需使用 CLI,就像 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.

然后转到 Heroku 上的附加组件列表,选择 PostgreSQL Studio,对其进行授权,从所有数据库的下拉列表中选择要连接的数据库,它将带您到基于 Web 的界面来处理您选择的数据库。

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

你可以参考这篇关于 Heroku 的官方文章:https: //devcenter.heroku.com/articles/pgstudio

回答by Nikhil

The easy answer is:

简单的答案是:

heroku pg:info

heroku pg: 信息

回答by Nate Sun

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.

你也可以下载一个客户端Postgres,比如Postico,并使用那个URL中提供的信息输入密码和数据库名称等,然后你就可以在本地创建,就像phpMyAdmin一样。

回答by Pavel Polushkin

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

您可以使用允许在线运行查询的 heroku 数据剪辑。在这里您可以找到文档https://devcenter.heroku.com/articles/dataclips

回答by Connor Leech

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

使用 Sequel Pro 连接到数据库。您可以使用heroku config命令找到您的 ClearDB 网址。连接结构如下:

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

回答by rtfminc

I use the admin_data gem, works well in Heroku.

我使用 admin_data gem,在 Heroku 中运行良好。