修改数据库中的数据
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()
article1.title = '文章标题11'
article1.content = '文章内容11'
db.session.commit()
article2 = Article.query.filter(Article.title == '文章标题1').first()
article2.title = '文章标题11'
article2.content = '文章内容11'
db.session.commit()
article3 = Article.query.filter_by(title='文章标题1').first()
article3.title = '文章标题11'
article3.content = '文章内容11'
db.session.commit()
article4 = Article.query.get(8)
article4.title = '文章标题11'
article4.content = '文章内容11'
db.session.commit()
return 'Hello World!'
if __name__ == '__main__':
app.run()