diff --git a/chassis/db_model.py b/chassis/db_model.py index 1be0e10..2cda20f 100644 --- a/chassis/db_model.py +++ b/chassis/db_model.py @@ -3,10 +3,13 @@ from sqlalchemy.ext.declarative import declarative_base from datetime import datetime BaseModel = declarative_base() +metadata = BaseModel.metadata class BaseCrud(BaseModel): + __abstract__ = True + # 硬删除 def delete(self, session, commit=False): session.delete(self) @@ -47,6 +50,8 @@ class BaseCrud(BaseModel): class InfoCrud(BaseModel): + __abstract__ = True + create_time = Column(DateTime(), default=func.now()) update_time = Column(DateTime(), default=func.now(), onupdate=func.now()) delete_time = Column(DateTime()) diff --git a/setup.py b/setup.py index c5e8f43..8e04e5b 100644 --- a/setup.py +++ b/setup.py @@ -60,6 +60,7 @@ setup( 'rocketry': ['rocketry==2.4.0'], 'gutter': ['gutter==0.5.0'], 'mysql': ['pymysql==1.0.3', - 'sqlalchemy==2.0.15'], + 'sqlalchemy==2.0.15', + 'sqlacodegen==2.3.0'], }, )