From eb1644736c1d95ca26d521c6fa9817b721a721f8 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Thu, 8 Jun 2023 21:41:50 +0800 Subject: [PATCH] update setup; update db_model --- chassis/db_model.py | 5 +++++ setup.py | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) 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'], }, )