官术网_书友最值得收藏!

Defining the database schema

The database schema is simple and inherited from the monolith. We care only about the thoughts, stored in the thought_model table, so the database structure is as follows:

The thought_model table

This table is represented in code in the thoughts_backend/models.py file, described in SQLAlchemy format with the following code:

class ThoughtModel(db.Model):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(50))
text = db.Column(db.String(250))
timestamp = db.Column(db.DateTime, server_default=func.now())

SQLAlchemy is capable of creating the table for testing purposes or for development mode. For this chapter, we defined the database to be SQLite, which stores the data in the db.sqlite3 file.

主站蜘蛛池模板: 三亚市| 乡宁县| 公安县| 台中县| 瓦房店市| 郎溪县| 佳木斯市| 福建省| 岢岚县| 彰化县| 拜城县| 罗平县| 蕉岭县| 全南县| 仁布县| 孟州市| 赤峰市| 兴和县| 清镇市| 沧州市| 湖南省| 江孜县| 福州市| 肃南| 达孜县| 北宁市| 西平县| 师宗县| 台南县| 永泰县| 钟祥市| 米易县| 西和县| 兴安盟| 丁青县| 鄂温| 高尔夫| 罗城| 临夏县| 永州市| 蚌埠市|