首先需要创建一个与数据库(SQLite)的连接。在web应用中,这个连接通常与request相关。它在处理request时创建,在response发送前关闭1。
文件结构:

db.py:

schema.sql
- drop tables
- create new tables
一些常用的列及属性:
| row_name | datatype | other setting |
|---|---|---|
| id | int | autoincrement |
| username | string | unique, not null |
| time | timestamp | current_timestamp as default, not null |
本文介绍了如何在Flask应用中建立与SQLite数据库的连接,强调了连接通常与request生命周期同步,即在处理请求时创建,响应发送前关闭。同时提到了包含`db.py`和`scheam.sql`文件的数据库初始化过程,以及数据库表的创建和常用列的定义。
447

被折叠的 条评论
为什么被折叠?



