Psycopg2 : error message.

D

dandrigo

Dear all,

I'm writing a python script for a web service. I have to connect to my
postgres/postgis databases via Psycopg2.

I writed a little first script just to connect to my pg/postgis db and drop
a test db.

But when i execute the python file, i have several error messages.

Please read the 2 usefull files below :

Dandrigo pg_test.py <http://python.6.x6.nabble.com/file/n5057062/pg_test.py>

SS_dos.JPG <http://python.6.x6.nabble.com/file/n5057062/SS_dos.JPG>


In advance, thank you to throw light for me.

Regards.
 
T

Tim Roberts

dandrigo said:
I'm writing a python script for a web service. I have to connect to my
postgres/postgis databases via Psycopg2.

I writed a little first script just to connect to my pg/postgis db and drop
a test db.

But when i execute the python file, i have several error messages.

Really, this wouldn't have been so hard to figure out if you had read the
documentation.

conn=psycopg2.connect("dbname='busard_test' user='laurent'
host='localhost' password='cactus'")

Psycopg2 has two ways to specify the parameters. You can either do them as
individual Python parameters, in which case each parameter is a string that
needs to be quited, OR you can use a single connection string, in which
case you do NOT quote the individual parameters.

So, you can either do this:

conn=psycopg2.connect("dbname=busard_test user=laurent host=localhost
password=cactus")

or do this:

conn=psycopg2.connect(database='busard_test', user='laurent',
host='localhost', password='cactus'")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,808
Messages
2,569,686
Members
45,452
Latest member
AmberLayde

Latest Threads

Top