Skip to content
Myr

Added an example for using the db connection without the request

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent cb54c46 · Browse files · 1 file+11 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+11 added−0 removed

  • other:+11 added−0 removed

1 file+11 added−0 removed

modified:docs/extensiondev.rst+11 added
248 unmodified lines
249 def show_all():250 cur = db.connection.cursor()251 cur.execute(...)252253Likewise if you are outside of a request but you are using Flask 0.9 or254later with the app context support, you can use the database in the same255way::256257 with app.app_context():258 cur = db.connection.cursor()259 cur.execute(...)260261At the end of the `with` block the teardown handles will be executed262automatically.263264Additionally, the ``init_app`` method is used to support the factory pattern265for creating apps::266267 db = Sqlite3()
152 unmodified lines