Returns a connection to the SQlite database. Within a Flask app context, this function applies a caching mechanism to avoid redundant initialization overhead. Outside a Flask app context, it creates a fresh DB connection on every invocation. Returns: sqlite3.dbapi2.connecti
()
| 7 | |
| 8 | |
| 9 | def get(): |
| 10 | """Returns a connection to the SQlite database. |
| 11 | |
| 12 | Within a Flask app context, this function applies a caching mechanism to |
| 13 | avoid redundant initialization overhead. Outside a Flask app context, it |
| 14 | creates a fresh DB connection on every invocation. |
| 15 | |
| 16 | Returns: |
| 17 | sqlite3.dbapi2.connection |
| 18 | """ |
| 19 | if not flask.has_app_context(): |
| 20 | return db.store.create_or_open(_DB_PATH) |
| 21 | |
| 22 | connection = _get_cached_flask_db() |
| 23 | if connection is None: |
| 24 | connection = db.store.create_or_open(_DB_PATH) |
| 25 | _cache_flask_db(connection) |
| 26 | return connection |
| 27 | |
| 28 | |
| 29 | def close(): |
nothing calls this directly
no test coverage detected