赞
踩
pip install aerich
from tortoise import Model, fields
class User(Model):
""" 用户基础信息 """
name = fields.CharField(max_length=24, description="姓名")
id_no = fields.CharField(max_length=24, description="身份证号")
TORTOISE_ORM = {
"connections": {"default": "mysql://root:password@localhost/basename"},
"apps": {
"models": {
# models对应上面创建的models.py
"models": ["aerich.models", "models"],
"default_connection": "default",
},
},
}
aerich init -t db.TORTOISE_ORM
aerich.ini
文件和一个migrations
文件夹aerich init-db
aerich migrate
# 在后面加 --name=xxx, 可以指定文件名
aerich upgrade
aerich downgrade
官方文档:https://github.com/tortoise/aerich
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。