[BangPypers] psycopg2 problem

Anand Chitipothu anandology at gmail.com
Mon Oct 26 12:16:55 CET 2009


> I was trying to connect to postgre db with Python psycopg2 . The code for
> connecting the db is
>
>    import psycopg2
>
>    try:
>        dbconn = psycopg2.connect( "dbname=%s user=%s\
>        host='localhost' password=%s" ) % ( dbname,dbuser, dbpass )
>    except:
>        raise

You are trying to pass all db parameters. You should be doing some
thing like this:

conn = psycopg2.connect(dbname=dbname, user=dbuser, password=dbpass)

Anand


More information about the BangPypers mailing list