当前位置:网站首页>Flask framework operation database_ Add, delete, modify and query statements
Flask framework operation database_ Add, delete, modify and query statements
2022-07-29 03:42:00 【Chen Fuguo】
1、 increase :
Create entity class objects ( Rows of the database ):
For example, to User In the table user_name and password add to ‘ Zhang San ’ and ‘123456’ The line of :
#1. Create objects
user1 = User(user_name=" Zhang San ",password="123456")
#2. Add session :
db.session.add(user1)
#3. Submit
db.session.commit()
2、 check
There is one for each model class query object ,
# For example, retrieve user modular ( surface ) All the lines in :
User.query.all()
# Search by condition , Use filters filter() To configure query object :
user1 = User.query.filter(User.user_name==' Zhang San ').first()
3、 Change :
#1、 Query and find the data that needs to be modified
user1 = User.query.filter(User.user_name==' Zhang San ').first()
#2、 Modify the line :
user1.user_name=' Zhang Xiaobao '
#3、 Commit transaction :
db.session.commit()
4、 Delete
#1、 Take out the data to be deleted :
user1 = User.query.filter(User.user_name==' Zhang San ').first()
#2、 Delete data :
db.session.delete(user1)
#3、 Commit transaction :
db.session.commit()
边栏推荐
- (2022杭电多校三)1002-Boss Rush(状压DP+二分)
- The difference between int and integer. Is int or integer used in practical applications?
- The latest second edition of comic novels, listening to books, three in one, complete source code / integrated visa free interface / building tutorials / with acquisition interface
- three. JS Part 54 how to pass structure array to shader
- 向日葵资深产品总监技术分享:“国民远控”如何在AD域环境下应用
- Excel splicing database statement
- Matlab learning -- structured programs and user-defined functions
- 1.5 nn. Module neural network (III)
- How to understand clock cycle and formula CPU execution time = number of CPU clock cycles / dominant frequency
- Overestimated test driven development?
猜你喜欢

Why does the 20 bit address bus determine the storage space of 1MB

@Configuration (proxybeanmethods = false) what's the use of setting this to false

Cloudera manager platform fault repair record

向日葵远程控制为何采用BGP服务器?自动最优路线、跨运营商高速传输

Beijing post network research 2015 problem2

Multi level wavelet CNN for image restoration

Process tracking of ribbon principle

(2022 Hangdian multi school III) 1011 link is as bear (thinking + linear basis)

Pp-yoloe details

NXP i.mx8mp-deepviewrt
随机推荐
Target detection, industrial defects, image segmentation -- deep learning data set induction
深入C语言(1)——操作符与表达式
How to realize multi line annotation in MATLAB
Code speed optimization
MOS tube - rapid recovery application notes (II) [parameters and applications]
What you see and think in Microsoft
for_ Example of each usage
VISO fast rendering convolution block
Cannot paste multiple pictures at once
力扣每日一题-第44天-205. 同构字符串
Introduction and comparison of unicast, multicast (target broadcast, multicast), broadcast, flooding, flooding
深入C语言(4)——switch的定义与使用
从2019 年开始,你一定停止使用了这个营销策略…
1.5 nn. Module neural network (III)
Matlab learning - accumulation of small knowledge points
(nowcoder22529C)dinner(容斥原理+排列组合)
(2022 Hangdian multi school III) 1002 boss rush (pressure dp+ dichotomy)
向日葵远程控制为何采用BGP服务器?自动最优路线、跨运营商高速传输
[redis series] string data structure
Beijing post network research 2015 problem2