Data Base - importing countries or currencies

Hello,
Question from a newbie
Context : Windows 10 Home / WSL 2 / Ubuntu 20.04 ; tryton:latest installed successfully using the docker procedure ; tryton is now « localhost :8000 » accessible

Executing in my « home » directory :

  • Command : TRYTOND_DATABASE_URI=‘postgresql://tryton:5432/tryton’ trytond_import_countries -d ‘postgresql://tryton:5432/tryton’
    Response : trytond_import_countries.py: command not found
  • Command : docker run --rm -ti tryton/tryton --pyrun trytond_import_countries.py
    Response : open(“trytond_import_countries.py”): No such file or directory [plugins/python/python_plugin.c line 1795]

Thank you, Marc

The name of the import script does not have .py, see: Setup — trytond_country latest documentation

Both Run #1 & #2 give no result in browser after refresh
Run #1:
docker run --rm -ti tryton/tryton --pyrun trytond_import_countries -d ‘postgresql://tryton:5432/tryton’
[uWSGI] getting INI configuration from /etc/uwsgi.conf
Run #2
postgres@LAPTOP-U8FF0ITJ:~$ docker run --rm -ti tryton/tryton --pyrun trytond_import_countries
[uWSGI] getting INI configuration from /etc/uwsgi.conf

Run #3 (adding “-c trytond.conf”) : error message
docker run --rm -ti tryton/tryton --pyrun trytond_import_countries -d ‘postgresql://tryton:5432/tryton’ -c trytond.conf
[uWSGI] getting INI configuration from /etc/uwsgi.conf
unable to load configuration from trytond.conf

Run #4 (adding reference to DB) : error message
docker run --rm -ti tryton/tryton --pyrun TRYTOND_DATABASE_URI=‘postgresql://tryton:5432/tryton’ trytond_import_countries -d ‘postgresql://tryton:5432/tryton’
[uWSGI] getting INI configuration from /etc/uwsgi.conf
unable to load configuration from trytond_import_countries

Thank you.

I do not know what is this --pyrun option. It is not a standard docker option.
Also the value of the --database option should be the database name only.

So you should run:

$ docker run --rm -ti tryton/tryton trytond_import_countries -d tryton

supposing that volumes and network are correctly configured.

I get could not translate host name “postgres”: name or servce not known when following that last reply.
I have the same issue as the OP.
I followed the docker instructions exactly, same db, same container etc

Found the answer in another topic.
need to use:

docker exec --interactive --tty tryton /entrypoint.sh python3 -m \ trytond.modules.country.scripts.import_countries -d tryton

Running the below, won’t find postgres even if the full uri is supplied:

$ docker run --rm -ti tryton/tryton trytond_import_countries -d tryton

If the above two commands are supposed to be equivalent, they currently are not as of the latest docker commit.

Context : WIndows 10 Home - PowerShell 7.0.0-rc.1 Admin - Docker - Tryton (2021-02-21)

Confirmed working :
import currencies

docker exec --interactive --tty tryton /entrypoint.sh python3 -m trytond.modules.currency.scripts.import_currencies -d tryton

import countries

docker exec --interactive --tty tryton /entrypoint.sh python3 -m trytond.modules.country.scripts.import_countries -d tryton

Thank you Mark !

Marc

These two commands are not exactly equivalent…

  • docker exec runs the command inside an existing container, whereas
  • docker run creates a new container and runs the command inside that

This difference means that, in this case, the environment that the commands are running in is slightly different.

If you followed the How to run Tryton using Docker guide, then you should also find the following commands work:

docker exec --interactive --tty tryton /entrypoint.sh trytond_import_countries -d tryton

And:

docker run --rm --interactive --tty --env DB_HOSTNAME=tryton-postgres --env DB_PASSWORD=${POSTGRES_PASSWORD} --network tryton tryton/tryton trytond_import_countries -d tryton

Thanks for pointing that out ! So to be complete :

  • my commands were indeed run towards “existing started” tryton container

  • Also worked as per your suggestion :
    docker exec --interactive --tty tryton /entrypoint.sh trytond_import_countries -d tryton
    docker exec --interactive --tty tryton /entrypoint.sh trytond_import_currencies -d tryton

  • docker version 20.10.2

  • suggestion from a newbie : best to run the above commands (in whatever format) after installing Tryton and before using other functions (companies, sales, etc.)