2020年4月8日

python @cached_property缓存装饰器

摘要: 源码:class cached_property(object): """ Decorator that converts a method with a single self argument into a property cached on the instance. Optional `` 阅读全文

posted @ 2020-04-08 17:05 不要挡着我晒太阳 阅读(817) 评论(0) 推荐(0) 编辑

sqlalchemy text() 函数

摘要: 作用:封装sql字符串 1. 不同数据库, 可以使用统一的sql参数传递写法. 参数须以:号引出. 在调用execute()的时候, 使用dict结构将实参传进去. from sqlalchemy import text result = db.execute(text('select * from 阅读全文

posted @ 2020-04-08 16:29 不要挡着我晒太阳 阅读(6844) 评论(0) 推荐(0) 编辑

理解SQLAlchemy的表继承关系(4)--高级应用

摘要: class Entry(AbstractConcreteBase, db.Model): """Base Class of Entry.""" id = db.Column(db.Integer, primary_key=True, nullable=False) created = db.Colu 阅读全文

posted @ 2020-04-08 13:58 不要挡着我晒太阳 阅读(302) 评论(0) 推荐(0) 编辑

理解SQLAlchemy的表继承关系(3)-Concrete Table Inheritance

摘要: Concrete Table Inheritance译成混合继承? 这种继承方式会创建一个ORM基类,然后在所有继承表中会创建包含ORM基类定义的字段的独立的表。 继承表与ORM基类的关系在数据库层面上没有外健关系,只是在语言层会有继承关系。 class Employee(AbstractConcr 阅读全文

posted @ 2020-04-08 13:57 不要挡着我晒太阳 阅读(343) 评论(0) 推荐(0) 编辑

理解SQLAlchemy的表继承关系(2)-Single Table Inheritance

摘要: Single Table Inheritance即单表继承,顾名思义,所有继承表的数据均保存在一个表。 该种继承比较容易理解。 class Employee(Base): __tablename__ = 'employee' id = Column(Integer, primary_key=True 阅读全文

posted @ 2020-04-08 11:53 不要挡着我晒太阳 阅读(424) 评论(0) 推荐(0) 编辑

理解SQLAlchemy的表继承关系(1)--Joined Table Inheritance

摘要: Joined Table Inheritance指通过外健方式进行链接实现的继承方式。 举个例子理解,共三个ORM类: Employee:员工,基类,具有id,name两个共有字段Manager:经理,继承Employee Engineer:工程师,继承Employee,在本例中,SQLAlchem 阅读全文

posted @ 2020-04-08 11:44 不要挡着我晒太阳 阅读(593) 评论(0) 推荐(0) 编辑

导航