Asterisk
Asterisk

Reputation: 3574

connect to remote postgres database using pylons and psycopg2

I am able to connect to my remote database using psycopg2 in standalone Python 2.6 program, but cannot establish connection from within controller in Pylons.

How can I do that?

EDIT: exception value I am getting is could not translate host name "localhost:7780" to address: Name or service not known

I am creating ssh tunnel to connect to remote database.

Upvotes: 2

Views: 3420

Answers (2)

Bharti Rawat
Bharti Rawat

Reputation: 2073

Set your Database settings like this.

 host='localhost' 
 port='7780' 
 dbname='mydatabase' 
 user='myusername' 
 password='mypassword'

Your error is just coming due to this setting host='localhost:7780'

Upvotes: 1

Asterisk
Asterisk

Reputation: 3574

Problem solved by changing url format from

"host='localhost:7780' dbname='mydb' user='me' password='mypassword'" to

"host='localhost' port='7780' dbname='mydb' user='me' password='mypassword'".

Upvotes: 4

Related Questions