flask的sqlalcheml配置
- 安装flask-sqlalcheml和pymysql
- pip install flask-sqlalcheml
- pip install pymysql
- 配置app.py文件
- from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import os
app = Flask(name)
app.config[‘SQLALCHEMY_DATABASE_URI’] = ‘sqlite:///’+os.path.join(os.path.dirname(file),‘test.sqlite3’)
app.config[‘SQLALCHEMY_CMMIT_ON_TEARDOWN’] = True
app.config[‘SQLALCHEMY_TRACK_MODIFICATIONS’] = True
db = SQLAlchemy(app)
6.编写models
7.models的类继承