通过用户模型,对数据库进行增删改查操作
生活随笔
收集整理的這篇文章主要介紹了
通过用户模型,对数据库进行增删改查操作
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
增加:
user =
db.session.add(user)
db.session.commit() #增加 user = User(username ='JACKSON',password='0328' ) db.session.add(user) db.session.commit() 查詢:
User.query.filter(User.username == 'mis1114').first() #查詢 user=User.query.filter(User.username =='JACKSON').first() print(user.username,user.password) 修改:
user.password = '111111'
db.session.commit() #修改 user=User.query.filter(User.username =='JACKSON').first() user.password='0116' db.session.commit() 刪除:
db.session.delete(user)
db.session.commit() #刪除 user=User.query.filter(User.username =='JACKSON').first() db.session.delete(user) db.session.commit()
user =
db.session.add(user)
db.session.commit() #增加 user = User(username ='JACKSON',password='0328' ) db.session.add(user) db.session.commit() 查詢:
User.query.filter(User.username == 'mis1114').first() #查詢 user=User.query.filter(User.username =='JACKSON').first() print(user.username,user.password) 修改:
user.password = '111111'
db.session.commit() #修改 user=User.query.filter(User.username =='JACKSON').first() user.password='0116' db.session.commit() 刪除:
db.session.delete(user)
db.session.commit() #刪除 user=User.query.filter(User.username =='JACKSON').first() db.session.delete(user) db.session.commit()
?
轉載于:https://www.cnblogs.com/JaTae/p/7852667.html
總結
以上是生活随笔為你收集整理的通过用户模型,对数据库进行增删改查操作的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: opencv3编程入门-毛星云
- 下一篇: 数据库常见错误