我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用models.db()。
def createdb(): """ Session-wide test database. :yield models.db: database module for models """ models.__create_tables() # pylint: disable=protected-access yield models.db models.__drop_tables() # pylint: disable=protected-access
def before_request(): g.db = models.db g.db.connect() g.user = current_user
def after_request(response): g.db.close() return response
def init(configObject): # this is not unheard of, pygame uses this trick though it's ugly. app.config.from_object(configObject) from models import db, all_tables global db, all_tables register_all_blueprints()