删除数据库中的数据
from flask import Flask
from exts import db
from models import Article
app = Flask(__name__)
app.config.from_pyfile('config.py')
db.init_app(app)
@app.route('/')
def index():
article1 = Article.query.first()
db.session.delete(article1)
db.session.commit()
article2 = Article.query.filter(Article.title == '文章标题1').first()
db.session.delete(article2)
db.session.commit()
article3 = Article.query.filter_by(title='文章标题1').first()
db.session.delete(article3)
db.session.commit()
article4 = Article.query.get(8)
db.session.delete(article4)
db.session.commit()
return 'Hello World!'
if __name__ == '__main__':
app.run()