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