Made grammar changes to the Tutorial.
This commit is contained in:
parent
8421c1ea0c
commit
86cc6f9806
10 changed files with 63 additions and 64 deletions
|
|
@ -6,7 +6,7 @@ Step 3: Creating The Database
|
|||
Flaskr is a database powered application as outlined earlier, and more
|
||||
precisely, an application powered by a relational database system. Such
|
||||
systems need a schema that tells them how to store that information. So
|
||||
before starting the server for the first time it's important to create
|
||||
before starting the server for the first time, it's important to create
|
||||
that schema.
|
||||
|
||||
Such a schema can be created by piping the `schema.sql` file into the
|
||||
|
|
@ -15,15 +15,15 @@ Such a schema can be created by piping the `schema.sql` file into the
|
|||
sqlite3 /tmp/flaskr.db < schema.sql
|
||||
|
||||
The downside of this is that it requires the sqlite3 command to be
|
||||
installed which is not necessarily the case on every system. Also one has
|
||||
to provide the path to the database there which leaves some place for
|
||||
errors. It's a good idea to add a function that initializes the database
|
||||
for you to the application.
|
||||
installed, which is not necessarily the case on every system. Also, one has
|
||||
to provide the path to the database which leaves some place for
|
||||
errors. It's a good idea to add a function to the application that
|
||||
initializes the database for you.
|
||||
|
||||
If you want to do that, you first have to import the
|
||||
:func:`contextlib.closing` function from the contextlib package. If you
|
||||
want to use Python 2.5 it's also necessary to enable the `with` statement
|
||||
first (`__future__` imports must be the very first import)::
|
||||
want to use Python 2.5, it's also necessary to enable the `with` statement
|
||||
(`__future__` imports must be the very first import)::
|
||||
|
||||
from __future__ import with_statement
|
||||
from contextlib import closing
|
||||
|
|
@ -52,8 +52,8 @@ execute a complete script. Finally we only have to commit the changes.
|
|||
SQLite 3 and other transactional databases will not commit unless you
|
||||
explicitly tell it to.
|
||||
|
||||
Now it is possible to create a database by starting up a Python shell and
|
||||
importing and calling that function::
|
||||
Now it is possible to create a database by importing and calling that function
|
||||
from within a Python shell::
|
||||
|
||||
>>> from flaskr import init_db
|
||||
>>> init_db()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue