Connect to the application's configured database. The connection is unique for each request and will be reused if this is called again.
()
| 7 | |
| 8 | |
| 9 | def 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 | |
| 23 | def close_db(e=None): |
no outgoing calls