MCPcopy Index your code
hub / github.com/tiny-pilot/tinypilot / get

Function get

app/db_connection.py:9–26  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

7
8
9def 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
29def close():

Callers

nothing calls this directly

Calls 2

_get_cached_flask_dbFunction · 0.85
_cache_flask_dbFunction · 0.85

Tested by

no test coverage detected