postgresql 如何在heroku中使用pg:psql?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14716325/
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-11 00:01:15  来源:igfitidea点击:

How to use pg:psql in heroku?

postgresqlherokuruby-on-rails-3.1

提问by simo

I am trying to detect my db at heroku terminal like this:

我正在尝试像这样在 heroku 终端检测我的数据库:

myapp@ubuntu:~/RubymineProjects/myapp$ heroku pg:info
The plugin heroku-sql-console has been deprecated. Would you like to remove it? (y/N) n
=== HEROKU_POSTGRESQL_JADE_URL (DATABASE_URL)
Plan:        Dev
Status:      available
Connections: 1
PG Version:  9.1.6
Created:     2012-10-10 19:59 UTC
Data Size:   9.1 MB
Tables:      32
Rows:        2802/10000 (In compliance)
Fork/Follow: Unsupported

So, I tried:

所以,我试过:

myapp@ubuntu:~/RubymineProjects/myapp$ heroku pg:psql
The plugin heroku-sql-console has been deprecated. Would you like to remove it? (y/N) n
psql (9.1.7, server 9.1.6)
SSL connection (cipher: **-**-****-**, bits: 256)
Type "help" for help.

I need to list all users records:

我需要列出所有用户记录:

dbfjinfaes61gb=> select * from users
dbfjinfaes61gb-> 

But above, nothing happened, what I am missing here?

但上面,什么也没发生,我在这里错过了什么?

回答by Clodoaldo Neto

You need a semicolon at the end of the query:

您需要在查询末尾使用分号:

select * from users;

回答by Leonardo Pineda

Run this

运行这个

heroku pg:psql -c "command" --app "name-app"

sample

样本

heroku pg:psql -c "\?" --app app-sample