[Ilugc] Help with PostgreSQL (psycopg)

  • From: parth.technofreak@xxxxxxxxx (Parthan)
  • Date: Wed Jul 19 14:22:48 2006

Hello,
I am trying to use PostgreSQL database in Python using psycopg. I have 
an issue, not basically with psycopg, but mainly with postgresql. I have 
created an account guest, with superuser privileges and permission to 
create tables, with a password 'guest'. When i try to use it for 
accessig database in my python program, i get an authentication failure 
error.

[python code]

from psycopg import connect
connection = connect("dbname=mydb user=guest password=guest")
cursor = connection.cursor()
cursour.execute("SELECT * FROM mytable")
......
......

[/python code]

But this gives me a "fatal error: Authentication failure" for user=guest 
incorrect password=guest. I made sure that the password is correct. I 
then checked the same using 'pgaccess' a GUI for accessing PostgreSQL 
database. I used the same dbname, username and password, and i was able 
to access my database, the 'mytable' table was there and had data i had 
earlier inserted from the command line.

when i give 'psql mydb' am able to get the 'mydb=>'prompt, and thats how 
i created mytable.

Where am i getting worng ? What is the proper method of setting up a 
user and password in PostgreSQL. I was earlier using MySQL and i had no 
such authentication problems. psql seems to a bit confusing as it 
doesn't have a 'user=<uname> password=<pword>' option as in mysql to get 
into mysql.
-- 
With Regards

Parthan ('technofreak')
------------------------------
Research Assistant @ NRC-FOSS and Python\PHP Developer
A Proud Tuxian and an Ubuntero

Other related posts: