增加:
db.session.add(user)
db.session.commit()

user = User(username = 'mis1114',password = 'hehe111')
db.session.add(user)
db.session.commit()

 

 查询:
User.query.filter(User.username == 'mis1114').first()

user = User.query.filter(User.username == 'mis1114').first()
user.password = 'hehe111'
db.session.commit()

 

修改:
user.password = '111111'
db.session.commit()

user = User.query.filter(User.username == 'mis1114').first()
user.password = '111111'
db.session.commit()

 

 删除:
db.session.delete(user)
db.session.commit()

user = User.query.filter(User.username == 'mis1114').first()
db.session.delete(user)
db.session.commit()

 

 posted on 2017-11-15 18:34  048刘思华  阅读(133)  评论(0编辑  收藏  举报