add Database, use so many commands like below:

>>> from app import db, models

# add Users
>>> u = models.User(nickname='john', email='john@email.com')
>>> db.session.add(u)
>>> db.session.commit()

>>> u = models.User(nickname='susan', email='susan@email.com')
>>> db.session.add(u)
>>> db.session.commit()

# get User
>>> users = models.User.query.all()
>>> users
[<User u'john'>, <User u'susan'>]
>>> for u in users:
...     print(u.id, u.nickname)
...
(1, u'john')
(2, u'susan')

# get User by ID
>>> u = models.User.query.get(1)
>>> print u
<User u'john'>
>>> u = models.User.query.get(2)
>>> print u
<User u'susan'>

# add post with user
>>> import datetime
>>> u = models.User.query.get(1)
>>> p = models.Post(body='my first post!', timestamp=datetime.datetime.utcnow(), author=u)
>>> db.session.add(p)
>>> db.session.commit()

# get all posts from a user
>>> u = models.User.query.get(1)
>>> u
<User u'john'>
>>> posts = u.posts.all()
>>> posts
[<Post u'my first post!'>]

# obtain author of each post
>>> for p in posts:
...     print(p.id,p.author.nickname,p.body)
...
1 john my first post!

# a user that has no posts
>>> u = models.User.query.get(2)
>>> u
<User u'susan'>
>>> u.posts.all()
[]

# get all users in reverse alphabetical order
>>> models.User.query.order_by('nickname desc').all()
[<User u'susan'>, <User u'john'>]
>>>

# delete all sessions for next
>>> users = models.User.query.all()
>>> for u in users:
...     db.session.delete(u)
...
>>> posts = models.Post.query.all()
>>> for p in posts:
...     db.session.delete(p)
...
>>> db.session.commit()
>>>

mysql> select * from user;
+----+----------+-----------------+
| id | nickname | email           |
+----+----------+-----------------+
|  1 | john     | john@email.com  |
|  2 | susan    | susan@email.com |
+----+----------+-----------------+
2 rows in set (0.01 sec)

mysql> select * from post;
+----+----------------+---------------------+---------+
| id | body           | timestamp           | user_id |
+----+----------------+---------------------+---------+
|  1 | my first post! | 2014-11-08 10:26:02 |       1 |
+----+----------------+---------------------+---------+
1 row in set (0.01 sec)