增加:
user =
db.session.add(user)
db.session.commit()
user=User(username='蜡笔小新',password='123456')
db.session.add(user)
db.session.commit()
![](https://images2017.cnblogs.com/blog/1232554/201711/1232554-20171117111156687-1364225161.png)
查询:
User.query.filter(User.username == 'mis1114').first()
user=User.query.filter(User.username=='蜡笔小新').first()
print('修改前;',user.id,user.password)
![](https://images2017.cnblogs.com/blog/1232554/201711/1232554-20171117111844093-685497301.png)
修改:
user.password = '111111'
db.session.commit()
user=User.query.filter(User.username=='蜡笔小新').first()
print('修改前;',user.id,user.password)
user.password='456789'
db.session.commit()
print('修改后;',user.id,user.password)
![](https://images2017.cnblogs.com/blog/1232554/201711/1232554-20171117111643952-665323652.png)
![](https://images2017.cnblogs.com/blog/1232554/201711/1232554-20171117111333171-2108657613.png)
删除:
db.session.delete(user)
db.session.commit()
user=User.query.filter(User.username=='蜡笔小新').first()
db.session.delete(user)
db.session.commit()
![](https://images2017.cnblogs.com/blog/1232554/201711/1232554-20171117113254640-1919019292.png)