forked from orbit-oss/flask
Tweaked sqlite3 documentation
This commit is contained in:
parent
54def62657
commit
bcba7eb397
1 changed files with 5 additions and 6 deletions
|
|
@ -26,12 +26,11 @@ Here is a simple example of how you can use SQLite 3 with Flask::
|
||||||
if db is not None:
|
if db is not None:
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
All the application needs to do in order to now use the database is have
|
Now, to use the database, the application must either have an active
|
||||||
an active application context (which is always true if there is a request
|
application context (which is always true if there is a request in flight)
|
||||||
in flight) or to create an application context itself. At that point the
|
or create an application context itself. At that point the ``get_db``
|
||||||
``get_db`` function can be used to get the current database connection.
|
function can be used to get the current database connection. Whenever the
|
||||||
Whenever the context is destroyed the database connection will be
|
context is destroyed the database connection will be terminated.
|
||||||
terminated.
|
|
||||||
|
|
||||||
Note: if you use Flask 0.9 or older you need to use
|
Note: if you use Flask 0.9 or older you need to use
|
||||||
``flask._app_ctx_stack.top`` instead of ``g`` as the :data:`flask.g`
|
``flask._app_ctx_stack.top`` instead of ``g`` as the :data:`flask.g`
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue