@mjhea0 Tried to fix this by refering to multiple resources. Can you please look into it?
- Cloned the repo,
- Build the images and spin up the containers, using:
$ docker-compose up -d --build
- Applying migrations it failed to connect with database with below traceback:
$ docker-compose exec backend aerich upgrade
Traceback (most recent call last):
File "/usr/local/bin/aerich", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.9/site-packages/aerich/cli.py", line 321, in main
cli()
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1656, in invoke
super().invoke(ctx)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/aerich/cli.py", line 45, in wrapper
loop.run_until_complete(f(*args, **kwargs))
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/usr/local/lib/python3.9/site-packages/aerich/cli.py", line 95, in cli
await Migrate.init(tortoise_config, app, location)
File "/usr/local/lib/python3.9/site-packages/aerich/migrate.py", line 66, in init
await Tortoise.init(config=config)
File "/usr/local/lib/python3.9/site-packages/tortoise/__init__.py", line 600, in init
await cls._init_connections(connections_config, _create_db)
File "/usr/local/lib/python3.9/site-packages/tortoise/__init__.py", line 392, in _init_connections
await connection.create_connection(with_db=True)
File "/usr/local/lib/python3.9/site-packages/tortoise/backends/asyncpg/client.py", line 106, in create_connection
raise DBConnectionError(f"Can't establish connection to database {self.database}")
tortoise.exceptions.DBConnectionError: Can't establish connection to database hello_fastapi_dev
Detailed traceback:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/tortoise/backends/asyncpg/client.py", line 103, in create_connection
self._pool = await asyncpg.create_pool(None, password=self.password, **self._template)
File "/usr/local/lib/python3.9/site-packages/asyncpg/pool.py", line 407, in _async__init__
await self._initialize()
File "/usr/local/lib/python3.9/site-packages/asyncpg/pool.py", line 435, in _initialize
await first_ch.connect()
File "/usr/local/lib/python3.9/site-packages/asyncpg/pool.py", line 127, in connect
self._con = await self._pool._get_new_connection()
File "/usr/local/lib/python3.9/site-packages/asyncpg/pool.py", line 477, in _get_new_connection
con = await connection.connect(
File "/usr/local/lib/python3.9/site-packages/asyncpg/connection.py", line 1981, in connect
return await connect_utils._connect(
File "/usr/local/lib/python3.9/site-packages/asyncpg/connect_utils.py", line 732, in _connect
con = await _connect_addr(
File "/usr/local/lib/python3.9/site-packages/asyncpg/connect_utils.py", line 632, in _connect_addr
return await __connect_addr(params, timeout, True, *args)
File "/usr/local/lib/python3.9/site-packages/asyncpg/connect_utils.py", line 682, in __connect_addr
await compat.wait_for(connected, timeout=timeout)
File "/usr/local/lib/python3.9/site-packages/asyncpg/compat.py", line 103, in wait_for
return await asyncio.wait_for(fut, timeout)
File "/usr/local/lib/python3.9/asyncio/tasks.py", line 479, in wait_for
return fut.result()
asyncpg.exceptions.InvalidCatalogNameError: database "hello_fastapi_dev" does not exist
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/aerich", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.9/site-packages/aerich/cli.py", line 321, in main
cli()
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1128, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1656, in invoke
super().invoke(ctx)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.9/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/aerich/cli.py", line 45, in wrapper
loop.run_until_complete(f(*args, **kwargs))
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/usr/local/lib/python3.9/site-packages/aerich/cli.py", line 95, in cli
await Migrate.init(tortoise_config, app, location)
File "/usr/local/lib/python3.9/site-packages/aerich/migrate.py", line 66, in init
await Tortoise.init(config=config)
File "/usr/local/lib/python3.9/site-packages/tortoise/init.py", line 600, in init
await cls._init_connections(connections_config, _create_db)
File "/usr/local/lib/python3.9/site-packages/tortoise/init.py", line 392, in _init_connections
await connection.create_connection(with_db=True)
File "/usr/local/lib/python3.9/site-packages/tortoise/backends/asyncpg/client.py", line 106, in create_connection
raise DBConnectionError(f"Can't establish connection to database {self.database}")
tortoise.exceptions.DBConnectionError: Can't establish connection to database hello_fastapi_dev