Home > OS >  How to check the output after heroku pg:sql?
How to check the output after heroku pg:sql?

Time:09-28

I'm trying to run a select statement on a Postgres database on a free Heroku app.

I am running these commands commands in cmd:

  1. Log in to heroku
  2. chcp 1252
  3. heroku pg:psql -app "my-app-name::DATABASE"

I then get prompted by:

--> Connecting to postgresql-rectangular-44045
psql (13.4)
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.

And I can now write to my-app-name::DATABASE=> but regardless of what I write I don't get a response just another line starting with my-app-name::DATABASE->. I also checked the Heroku application logs (all processes) to see if the output got printed there but it was empty.

Am I missing something?

CodePudding user response:

And I can now write to my-app-name::DATABASE=> but regardless of what I write I don't get a response just another line starting with my-app-name::DATABASE->

Those two prompts are subtly different: the first ends with => and the second with ->.

The -> prompt indicates that psql is waiting for more input for the same query, e.g. in case you want to split your query up into several lines for readability.

Make sure to terminate each query with ; so psql knows you're done.

See the first example here for more.

CodePudding user response:

You can access psql using heroku pg:psql -a <app name> only, you do not need to include anything more like ::DATABASE.

In case you have more than 1 database, Heroku will connect to the one in the variable DATABASE_URL. If you want to select another database: pg:psql <database name> -a <appname>

In case you do not know your database name use the command heroku addons -a <app name>

  • Related