This commit is contained in:
long2ice
2020-08-10 17:31:36 +08:00
parent a3ce8ba035
commit ae339347d6
3 changed files with 31 additions and 17 deletions

View File

@ -2,6 +2,7 @@ import importlib
from copy import deepcopy
from passlib.context import CryptContext
from tortoise import Tortoise
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
@ -57,3 +58,13 @@ def import_obj(path: str):
module = ".".join(splits[:-1])
class_name = splits[-1]
return getattr(importlib.import_module(module), class_name)
def get_all_models():
"""
get all tortoise models
:return:
"""
for tortoise_app, models in Tortoise.apps.items():
for model_item in models.items():
yield model_item