Compose-frontend does not access the database

I am trying to run the following command:

python3 --compose-frontend run kpi python ./ shell

but when I run the following command for example:


I get this message:

  File "/opt/venv/lib/python3.8/site-packages/django/db/backends/sqlite3/", line 383, in execute
return Database.Cursor.execute(self, query, params)

django.db.utils.OperationalError: no such table: auth_user

Which clearly indicates that I am not running with the correct env variables that allow me to connect to the Postgresql database.
How can I run a shell and connect to the already running db?

I have understood that I had to specify the database so:

python3 --compose-frontend run --rm kpi django-admin  loaddata --database=kobocat /srv/src/kpi/media/dump_users.json

now works but I got this error:

raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.

Does anybody know a better way to use datadumps to move databases and tables?

Hi @paoloc68,

I think you are facing this issue
As a workaround. You can enter the container (./ -cf exec kpi bash) and then run ./ shell_plus

Otherwise you can export DATABASE_URL within the command

./ -e DATABASE_URL=postgis://<username>:<password>@postgres.kobo.private:5432/koboform --rm kpi python ./ shell_plus

Please update postgres.kobo.private and koboform with your settings.