I've written a simple sqlalchemy-django model, according to this manual: http://lethain.com/replacing-django-s-orm-with-sqlalchemy/, which worked for me pretty well.
My Django is connected to a remote postgresql database, with this settings:
DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
    'NAME': 'wetlab_dev',                               # Or path to database file if using sqlite3.
    'USER': 'limlim',                                 # Not used with sqlite3.
    'PASSWORD': '',                                     # Not used with sqlite3.
    'HOST': 'cab-27',                                   # Set to empty string for localhost. Not used with sqlite3.
    'PORT': '',                                         # Set to empty string for default. Not used with sqlite3.
    }
}
It worked for me a few days ago, but now when I try to load the 'homepage' again, it shows me the following error message:
(OperationalError) FATAL:  Ident authentication failed for user "limlim"    
The sqlalchemy engine-configuration is:
CONNECTION_STR = 'postgresql://limlim:@cab-27/wetlab_dev'
engine = sqlalchemy.create_engine(CONNECTION_STR)   
It seems like I haven't changed anything that is related to the database configurations, but still I get this error message.
Also, when I try to connect to the database on the remote server with my username, I succeed doing it, so I guess it's not a problem of permissions for my username to get to this database.  
What can be done to overcome this error?
Your pg_hba.conf is configured to use 'ident' authentication for connections from localhost (127.0.0.1). You need it to be changed to md5 for your database and user combination.
@Craig is right, have to update the authentication method of the database user in the file pg_hba.conf, here what I've done:
sudo nano /var/lib/pgsql/data/pg_hba.conf
Go to the bottom of the file, then change the method from ident to md5 on the IPv4 and IPv6 rows:
# TYPE  DATABASE        USER            ADDRESS                 METHOD
# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5  # <- here
# IPv6 local connections:
host    all             all             ::1/128                 md5  # <- and here
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                peer
#host    replication     postgres        127.0.0.1/32            ident
#host    replication     postgres        ::1/128                 ident
Happy Coding :)
  local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust < from ident to trust 
# IPv6 local connections:
host    all             all             ::1/128                 trust < i changed this from ident to trust 
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            ident
host    replication     all             ::1/128                 ident
Don't forget to restart postgresql:
sudo systemctl restart postgresql
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With