jac300
jac300

Reputation: 5222

How to View My Postgres DB Schema from Command Line

So I have my Django app running and I just added South. I performed some migrations which worked fine locally, but I am seeing some database errors on my Heroku version. I'd like to view the current schema for my database both locally and on Heroku so I can compare and see exactly what is different. Is there an easy way to do this from the command line, or a better way to debug this?

Upvotes: 2

Views: 4413

Answers (3)

jeasoft
jeasoft

Reputation: 166

django also provides a management command that will display the sql for any app you have configure in your project, regardless of the database manager (SQLite, MySQL, etc) that you're using:

python manage.py sqlall <app name>

Try it! It could be usefull!

Upvotes: 0

John Beynon
John Beynon

Reputation: 37507

From the command line you should be able to do heroku pg:psql to connect directly via PSQL to your database and from in there \dt will show you your tables and \d <tablename> will show you your table schema.

Upvotes: 3

dm03514
dm03514

Reputation: 55962

locally django provides a management command that will launch you into your db's shell.

python manage.py dbshell

Upvotes: 2

Related Questions