我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用flask.g.sqlite_db()。
def get_db(): """Opens a new database connection if there is none yet for the current application context. """ if not hasattr(g, 'sqlite_db'): g.sqlite_db = connect_db() return g.sqlite_db
def close_db(error): """Closes the database again at the end of the request.""" if hasattr(g, 'sqlite_db'): g.sqlite_db.close()
def get_db(): """ Opens a new database connection if there is none yet for the current application context. """ if not hasattr(g, 'sqlite_db'): g.sqlite_db = connect_db() return g.sqlite_db
def get_db(): '''Opens a new database connection if there is none yet for the current application context.''' if not hasattr(g, 'sqlite_db'): g.sqlite_db = connect_db() debug('Database connection created.') return g.sqlite_db
def close_db(error): '''Closes the database again at the end of the request.''' if hasattr(g, 'sqlite_db'): g.sqlite_db.close() debug('Database connection destroyed.')
def get_db(): # g is a general purpose variable associated with the current application context if not hasattr(g, 'sqlite_db'): g.sqlite_db = connect_db() return g.sqlite_db # initialise the db
def db_open(): """Opens a new database connection if there is none yet for the current application context. """ if not hasattr(g, 'sqlite_db'): g.sqlite_db = db_connect() return g.sqlite_db
def close_db(error): """Closes the database again at the end of the request.""" if hasattr(g, 'sqlite_db'): g.sqlite_db.close() ################################################################################ # Intersections ################################################################################
def get_db(): if not hasattr(g, 'sqlite_db'): g.sqlite_db = connect_db() return g.sqlite_db
def close_db(error): if hasattr(g, 'sqlite_db'): g.sqlite_db.close()