0

I am trying to connect Django with postgres but i am getting this error

this is my setting.py:

'default' : {
    'ENGINE' : 'django.db.backends.postgresql_psycopg2',
    'NAME' : 'login',
    'USERNAME' : 'postgres',
    'PASSWORD' :'123',
    'HOST' : 'localhost',
    'PORT' : '5432'
}
8
  • 2
    The user name in the error message (=> "tbosss") doesn't match your settings (=> "USERNAME: 'postgres'"). Commented Dec 26, 2018 at 11:46
  • that the problem its not connecting at all Commented Dec 26, 2018 at 12:28
  • try add this line in db settings 'ATOMATIC_REQUESTS':True, Commented Dec 26, 2018 at 12:31
  • 1
    I repeat: The user name in the error message (=> "tbosss") doesn't match your settings (=> "USERNAME: 'postgres'"). Either you're using different settings than those you posted or you're trying to manually connect to the db at some point with a different username, but in both cases no one can help you debug this kind of problem without correct informations (and even then - postgres is kind of PITA when it comes to permissions). Commented Dec 26, 2018 at 12:33
  • @c.grey this should be "ATOMIC" (not "ATOMATIC"), and it won't solve the problem anyway. Commented Dec 26, 2018 at 12:34

1 Answer 1

2

psql (default client for PostgreSQL) tries to connect with current OS user when no user specified and I think that psycopg2 does that too.

The PostgreSQL documentation contains the complete list of the supported parameters. Also note that the same parameters can be passed to the client library using environment variables.

http://initd.org/psycopg/docs/module.html

https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS

When I check psycopg2 tutorial, I see that USERNAME option must be changed to USER.

psycopg2.connect("dbname='template1' user='dbuser' host='localhost' password='dbpass'")

https://wiki.postgresql.org/wiki/Psycopg2_Tutorial

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.