Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases

Alexey Papin
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexey Papin
iOS Development Techdegree Graduate 26,950 Points

PostgreSQL database deployed on Heroku - possible view, add, delete rows in tables?

Deployed PostgreSQL database on Heroku. Can connect to using Heroku command line tool. Can I use commands SELECT, INSERT INTO or DELETE on tables of my database and how to do it?

5 Answers

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

It looks like on Heroku should be psql command line tool available:

https://devcenter.heroku.com/articles/heroku-postgresql

https://devcenter.heroku.com/articles/heroku-postgresql#pg-psql

So it looks to me that after typing heroku pg:psql you should be connected to your database and be able to run any queries, see example in the last link.

Have you tried that?

Alexey Papin
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexey Papin
iOS Development Techdegree Graduate 26,950 Points

Sure, indeed, thats it what I'm talking about. I can connect, I can see tables, I can see structure of each table, but I can not manipulate data in that tables (execute commands like SELECT, INSERT, DELETE) - all my SQL queries ignored. I have no idea, may be user on Heroku does not have needed roles for that, may be I'm wrong with syntax, support of Heroku does not help.

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

So what I would do in your case,

first to try things out locally psql is installable app. And the web application you deployed should have POSTGRESQL database on your local machine. Try that out, execute commands if they work or not.

Second, when you get this done on local machine with local database, try to download database from your app from heroku:

 heroku pg:pull HEROKU_POSTGRESQL_MAGENTA mylocaldb --app sushi

Took this from here:

https://devcenter.heroku.com/articles/heroku-postgresql#pg-push-and-pg-pull

Also I would turn on logging, they say that can also help, somewhat like this:

heroku logs -p postgres -t

Took from here:

https://devcenter.heroku.com/articles/heroku-postgresql#logging

Did you turn on logging BTW ?