sxszzhrrt
V2EX  ›  问与答

Tortoise ORM+aerich 数据库初始化遇到问题

  •  
  •   sxszzhrrt · Dec 16, 2024 · 1209 views
    This topic created in 555 days ago, the information mentioned may be changed or developed.

    RT ,我的项目是 FastAPI+Tortoise ORM+aerich ,项目的结构如下所示:

    image.png

    其中红箭头指的是模型的定义文件,内容是这样的: image.png

    ./config/settings.py 文件是这样写的

    from tortoise import Tortoise
    TORTOISE_ORM = {
        "connections": {
            "default": "sqlite://db.sqlite3",
            },
        "apps": {
            "models": {
                "models": [
                            "apps.historyDay.entities.historyDayCache",
                            "apps.oilPrice.entities.oilPriceCache"
                        ],
                "default_connection": "default",
            }
        }
    }
    

    运行aerich init-db报错: image.png

    我尝试过在 entities 目录下创空白的__init__.py文件,也是不起作用的

    请问各位大佬应该怎么解决?

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   965 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 19:17 · PVG 03:17 · LAX 12:17 · JFK 15:17
    ♥ Do have faith in what you're doing.