Python app.db 模块,Model() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用app.db.Model()

项目:do-portal    作者:certeu    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        super(Model, self).__init__(**kwargs)
        # do custom initialization here
项目:markbj    作者:chaijunit    | 项目源码 | 文件源码
def paginate(query, page, per_page=20, error_out=True):
    """
    ????????db.session.query??????????db.Model????????
    ??db.session.query????????paginate??? ????????
    """
    if error_out and page < 1:
        abort(404)
    items = query.limit(per_page).offset((page - 1) * per_page).all()
    if not items and page != 1 and error_out:
        abort(404)
    if page == 1 and len(items) < per_page:
        total = len(items)
    else:
        total = query.order_by(None).count()
    return Pagination(query, page, per_page, total, items)
项目:template-for-flask    作者:GalaIO    | 项目源码 | 文件源码
def make_shell_context():
    reflec_maps = {}
    from app import models
    for obj_name in models.__dict__:
        obj = getattr(models, obj_name)
        if hasattr(obj, '__bases__') and obj.__bases__[0] is db.Model:
            reflec_maps[obj_name] = obj
    reflec_maps['app'] = app
    reflec_maps['db'] = db
    return reflec_maps