Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use pg:psql in heroku?

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

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?

like image 278
simo Avatar asked Feb 05 '13 20:02

simo


People also ask

Can you host PostgreSQL on Heroku?

Heroku Postgres is a managed SQL database service provided directly by Heroku. You can access a Heroku Postgres database from any language with a PostgreSQL driver, including all languages officially supported by Heroku.

How can I see my table in Heroku Postgres?

From the application dashboard on Heroku, go to the 'resources' tab and search for postgres. Provision it and use the free option. There's now a clickable link to the Datastore associated with your application. Go ahead and open the link to your datastore, and take note of exactly how to get here again.


2 Answers

You need a semicolon at the end of the query:

select * from users; 
like image 130
Clodoaldo Neto Avatar answered Oct 04 '22 04:10

Clodoaldo Neto


Run this

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

sample

heroku pg:psql -c "\?" --app app-sample 
like image 27
Leonardo Pineda Avatar answered Oct 04 '22 06:10

Leonardo Pineda