MCPcopy
hub / github.com/pallets/flask / get_db

Function get_db

examples/tutorial/flaskr/db.py:9–20  ·  view source on GitHub ↗

Connect to the application's configured database. The connection is unique for each request and will be reused if this is called again.

()

Source from the content-addressed store, hash-verified

7
8
9def get_db():
10 """Connect to the application's configured database. The connection
11 is unique for each request and will be reused if this is called
12 again.
13 """
14 if "db" not in g:
15 g.db = sqlite3.connect(
16 current_app.config["DATABASE"], detect_types=sqlite3.PARSE_DECLTYPES
17 )
18 g.db.row_factory = sqlite3.Row
19
20 return g.db
21
22
23def close_db(e=None):

Callers 15

test_author_requiredFunction · 0.90
test_createFunction · 0.90
test_updateFunction · 0.90
test_deleteFunction · 0.90
test_registerFunction · 0.90
test_get_close_dbFunction · 0.90
appFunction · 0.90
init_dbFunction · 0.85
indexFunction · 0.85
get_postFunction · 0.85
createFunction · 0.85
updateFunction · 0.85

Calls

no outgoing calls

Tested by 7

test_author_requiredFunction · 0.72
test_createFunction · 0.72
test_updateFunction · 0.72
test_deleteFunction · 0.72
test_registerFunction · 0.72
test_get_close_dbFunction · 0.72
appFunction · 0.72