Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres FATAL database does not exist Django

I have seen many of these questions asked for Ruby but not for DJango. We have a postgres DB and created a table name Adam with our postgres user. When you psql -l the table shows up. However, when trying to run a migrate we get an error.

FATAL:  database "/var/lib/pgsql/9.3/data/Adam" does not exist

The psql -l shows this:

Name       |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
-----------------+----------+----------+-------------+-------------+-----------------------
 Adam      | postgres     | UTF8     | en_US.UTF-8 | en_US.UTF-8 |

Django settings.py looks like..

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': os.path.join('/var/lib/pgsql/9.3/data/', 'Adam'),
        'USER': 'postgres',
        'PASSWORD': 'correctlyTypePassword'
    }
}

Any ideas why it thinks this doesn't exist?

like image 668
Adam Avatar asked Feb 13 '23 06:02

Adam


1 Answers

Your database settings are wrong. The key "Name" should refer to the database name not its path. Try this:

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': 'Adam',
    'USER': 'postgres',
    'PASSWORD': 'correctlyTypePassword'
    }
}
like image 179
yorodm Avatar answered Feb 16 '23 10:02

yorodm