Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the URL path to a local postgres database?

I have a Rails app running on a postgres database. I'm setting up a background task queue running on the database, and I need to specify the database URL.

The various permutations I've tried and would expect all return FATAL: database "database-name" does not exist.

Is there a command that will print this URL?

Or, what should the URL look like if my database.yml looks like this

development:
    adapter: postgresql
    encoding: unicode
    database: db/database-name

Thanks for suggestions.

like image 933
Andy Harvey Avatar asked May 17 '12 09:05

Andy Harvey


1 Answers

The format appears to be

postgres://username:password@host/database

You have a / in your database name and (apparently) postgres will accept / in database names, so you need to use either

postgres:///db/database-name

or

postgres:///db%2Fdatabase-name

Feel free to take out the db/ part of your database name - it's only warranted for databases like SQLite that store the db in a local file and need a filename.

like image 140
Michael Slade Avatar answered Oct 14 '22 19:10

Michael Slade