2010-05-26 20:49:01 +08:00
|
|
|
.. _tutorial-schema:
|
|
|
|
|
2010-04-18 19:15:00 +08:00
|
|
|
Step 1: Database Schema
|
|
|
|
=======================
|
|
|
|
|
2016-07-06 08:30:59 +08:00
|
|
|
In this step, you will create the database schema. Only a single table is
|
|
|
|
needed for this application and it will only support SQLite. All you need to do
|
|
|
|
is put the following contents into a file named :file:`schema.sql` in the
|
|
|
|
:file:`flaskr/flaskr` folder:
|
2010-04-18 19:15:00 +08:00
|
|
|
|
|
|
|
.. sourcecode:: sql
|
|
|
|
|
|
|
|
drop table if exists entries;
|
|
|
|
create table entries (
|
|
|
|
id integer primary key autoincrement,
|
2012-12-26 13:05:18 +08:00
|
|
|
title text not null,
|
2014-07-01 22:57:50 +08:00
|
|
|
'text' text not null
|
2010-04-18 19:15:00 +08:00
|
|
|
);
|
|
|
|
|
2016-07-06 08:30:59 +08:00
|
|
|
This schema consists of a single table called ``entries``. Each row in
|
2014-12-13 14:52:36 +08:00
|
|
|
this table has an ``id``, a ``title``, and a ``text``. The ``id`` is an
|
2010-04-18 19:15:00 +08:00
|
|
|
automatically incrementing integer and a primary key, the other two are
|
|
|
|
strings that must not be null.
|
2010-05-26 20:49:01 +08:00
|
|
|
|
|
|
|
Continue with :ref:`tutorial-setup`.
|