$ podman run --rm --name songbook-test -e SECRET_KEY=aaabbbccc -p 8080:80 songbook:latest
INFO: Started server process [1]
INFO: Waiting for application startup.
ERROR: Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1969, in _exec_single_context
self.dialect.do_execute(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 922, in do_execute
cursor.execute(statement, parameters)
sqlite3.OperationalError: no such table: song
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 677, in lifespan
async with self.lifespan_context(app) as maybe_state:
File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 566, in __aenter__
await self._router.startup()
File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 656, in startup
handler()
File "/code/app/main.py", line 41, in on_startup
utils.build_all_songs()
File "/code/app/utils.py", line 47, in build_all_songs
songs = session.query(Song).all()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/query.py", line 2693, in all
return self._iter().all() # type: ignore
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/query.py", line 2847, in _iter
result: Union[ScalarResult[_T], Result[_T]] = self.session.execute(
File "/usr/local/lib/python3.9/site-packages/sqlmodel/orm/session.py", line 129, in execute
return super().execute(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 2308, in execute
return self._execute_internal(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 2190, in _execute_internal
result: Result[Any] = compile_state_cls.orm_execute_statement(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/context.py", line 293, in orm_execute_statement
result = conn.execute(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1416, in execute
return meth(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/elements.py", line 516, in _execute_on_connection
return connection._execute_clauseelement(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1639, in _execute_clauseelement
ret = self._execute_context(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1848, in _execute_context
return self._exec_single_context(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1988, in _exec_single_context
self._handle_dbapi_exception(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 2343, in _handle_dbapi_exception
raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1969, in _exec_single_context
self.dialect.do_execute(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 922, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: song
[SQL: SELECT song.id AS song_id, song.title AS song_title, song.lytex AS song_lytex, song.verses AS song_verses, song.source_id AS song_source_id, song.pdf_path AS song_pdf_path
FROM song]
(Background on this error at: https://sqlalche.me/e/20/e3q8)
ERROR: Application startup failed. Exiting.
I believe this can be fixed by adding the database init and build in the container RUN steps.
Reproduce:
I believe this can be fixed by adding the database init and build in the container RUN steps.