增加:
db.session.add(user)
db.session.commit()
# 创建用户
user=User(username='meow2',password='meow2222',nickname='miao~')
db.session.add(user)
db.session.commit()
查询:
User.query.filter(User.username == 'mis1114').first()
user=User.query.filter(User.username=='meow1').first()
print(user.username,user.password)
修改:
user.password = '111111'
db.session.commit()
# 修改密码
user=User.query.filter(User.username=='meow1').first()
user.password='9999999999999'
db.session.commit()
删除:
db.session.delete(user)
db.session.commit()
# 删除
user=User.query.filter(User.username=='meow2').first()
db.session.delete(user)
db.session.commit()