当前位置:网站首页>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()
边栏推荐
- Cannot paste multiple pictures at once
- Common methods of lodash Library
- I.MX6U-驱动开发-2-LED驱动
- three.js 第五十四用如何给shader传递结构体数组
- Simple code implementation of K-means clustering
- What you see and think in Microsoft
- 1.4 nn. Module neural network (II)
- (2022 Hangdian multi school III) 1002 boss rush (pressure dp+ dichotomy)
- Rdkit II: use rdkit screening to screen 2D pharmacophores of chemical small molecules
- SFTP upload error: com.jcraft.jsch JSchException: connection is closed by foreign host
猜你喜欢

Cloudera manager platform fault repair record

Deep into C language (3) -- input and output stream of C

Excel splicing database statement

Realize multi-level linkage through recursion

Microcomputer principle and interface technology

RHCE's at, crontab's basic operations, the Chrony service, symmetric encryption and asymmetric encryption

通过递归实现多级联动

Arm architecture and neural network

Matlab learning -- structured programs and user-defined functions

What you see and think in Microsoft
随机推荐
2. Variables and scope
3.1 common neural network layer (I) image correlation layer
Build redis environment under windows and Linux
(2022杭电多校三)1002-Boss Rush(状压DP+二分)
I.MX6U-驱动开发-2-LED驱动
What have I learned from 200 machine learning tools?
Inclusion exclusion principle
In depth C language (4) -- definition and use of switch
消费行业数字化升级成 “刚需”,weiit 新零售 SaaS 为企业赋能!
Rdkit II: use rdkit screening to screen 2D pharmacophores of chemical small molecules
Simple code implementation of decision tree
深入C语言(2)——结构的定义与使用
Target detection, industrial defects, image segmentation -- deep learning data set induction
后缀自动机(sam)板子 from jly
Microcomputer principle and interface technology
Exness: dove resolution helped gold rebound, and the focus turned to U.S. GDP
Whole process record of yolov3 target detection
2. 变量及作用域
Web uploader cannot upload multiple files
Sleuth+Zipkin 来进行分布式服务链路的追踪