aerich icon indicating copy to clipboard operation
aerich copied to clipboard

ValueError: Empty module name

Open maxim-s-barabash opened this issue 4 years ago • 3 comments

aerich 0.2.1 tortoise-orm 0.16.12

I accidentally specified the wrong module name and got an error

aerich init --location . -t help
Success create migrate location .
Success generate config file aerich.ini

aerich.ini

[aerich]
tortoise_orm = help
location = ./
aerich init-db
...
File "/usr/local/lib/python3.7/dist-packages/aerich/cli.py", line 58, in cli
    tortoise_config = get_tortoise_config(ctx, tortoise_orm)
File "/usr/local/lib/python3.7/dist-packages/aerich/utils.py", line 38, in get_tortoise_config
    config_module = importlib.import_module(config_path)
File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1003, in _gcd_import
File "<frozen importlib._bootstrap>", line 942, in _sanity_check
ValueError: Empty module name

maxim-s-barabash avatar Jul 13 '20 21:07 maxim-s-barabash

Just run aerich init

long2ice avatar Jul 14 '20 01:07 long2ice

I am having the same problem, but I think my problem is my own misunderstanding of what is needed in config. I have a fastapi app, with the file structure below. What am I doing wrong? Thank you

app
    |-- main.py
    |-- db
           |-- models.py
           |-- schemas.py
    |-- auth
           |-- users.py 

Here is my config setup,(from main.py) I'm specifically unsure what is being represented under the apps key.

tortoise_config = {
   "connections": {"default": "postgres://user:password@localhost:5432/mydb"},
   "apps": {
       #should this key be fastapi appname or my project folder
       "app": {
           #i've seen this key as modules or models, im not sure which is correct
           "models": ["db.models", "aerich.models"],
           "default_connection": "default",
       },
   },
}

register_tortoise(
   app,
   config=tortoise_config,
   generate_schemas=True,
   add_exception_handlers=True
)

trevordanahy avatar Mar 23 '21 01:03 trevordanahy

Just manual update content in aerich.ini or delete it and rerun aerich init -t tortoise_config_path

long2ice avatar Mar 23 '21 01:03 long2ice