Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

FATAL: database "engine" does not exist #41

Open
haharay opened this issue Aug 23, 2019 · 3 comments
Open

FATAL: database "engine" does not exist #41

haharay opened this issue Aug 23, 2019 · 3 comments

Comments

@haharay
Copy link

haharay commented Aug 23, 2019

hello,
when running the "docker-compose run web python manage.py migrate" for local development, i get:
Starting app_postgres_1 ... done
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
self.connect()
File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 194, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/local/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 168, in get_new_connection
connection = Database.connect(**conn_params)
File "/usr/local/lib/python3.6/site-packages/psycopg2/init.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL: database "engine" does not exist

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "manage.py", line 22, in
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.6/site-packages/django/core/management/init.py", line 371, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.6/site-packages/django/core/management/init.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 79, in handle
executor = MigrationExecutor(connection, self.migration_progress_callback)
File "/usr/local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 18, in init
self.loader = MigrationLoader(self.connection)
File "/usr/local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 49, in init
self.build_graph()
File "/usr/local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 207, in build_graph
self.applied_migrations = recorder.applied_migrations()
File "/usr/local/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 61, in applied_migrations
if self.has_table():
File "/usr/local/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 44, in has_table
return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 255, in cursor
return self._cursor()
File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 232, in _cursor
self.ensure_connection()
File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
self.connect()
File "/usr/local/lib/python3.6/site-packages/django/db/utils.py", line 89, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 216, in ensure_connection
self.connect()
File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 194, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/local/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 168, in get_new_connection
connection = Database.connect(**conn_params)
File "/usr/local/lib/python3.6/site-packages/psycopg2/init.py", line 130, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: FATAL: database "engine" does not exist

P.S.
However, "docker-compose run web pytest":
Starting app_postgres_1 ... done
.....
======================== 11 passed, 4 warnings in 9.61s =========================

P.S.
When i Open an interactive shell in engine docker container by "docker-compose run engine bash", then Create super user account by "python manage.py createsuperuser", i get similar error.
I try "python manage.py createdb", getting the result: Unknown command: 'createdb' .

Thanks!

@renatoparedes
Copy link

renatoparedes commented Sep 3, 2019

Hello,

I am having this same issue. I first tried running

"docker-compose run engine python manage.py migrate"

and got

ERROR: No such service: engine

Then, I tried "docker-compose run web python manage.py migrate" and got the same output as haharay.

Thanks!

@renatoparedes
Copy link

Hello !

Checking to see if there have been any updates for this issue?

Cheers!

@raco
Copy link

raco commented Oct 2, 2019

You need to create the "engine" db, access the postgres container
sudo docker exec -it app_postgres_1 bash
inside the container
psql -U postgres
to access postgres db
then just create the "engine" db
CREATE DATABASE engine; \q;
get back to the local machine, re-run your command line and you'll see migrations in action.

hope it can be useful for you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants