当前位置:网站首页>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()
边栏推荐
- Multi level wavelet CNN for image restoration
- HDU multi School Game 2 1011 DOS card
- ROS - create workspace
- Notes on letter symbol marking of papers
- exness:鸽派决议帮助黄金反弹,焦点转向美国GDP
- How to judge stun protocol
- RTP 发送 和接收 h265
- Machine learning based on deepchem
- JS regular expression finds the number of times a character (string) appears (one line of code)
- 容斥原理
猜你喜欢

深入C语言(3)—— C的输入输出流

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

Deep understanding of Base64 underlying principles

What you see and think in Microsoft

Android view system and custom view Series 1: (kotlin version)

KNN method predicts pregnancy, KNN principle simple code

数字孪生实际应用案例-智慧能源篇

Use of leak scanning (vulnerability scanning) tool burpsuite or burp Suite (with installation and installation package download of burpsuite+1.7.26)

Realize multi-level linkage through recursion

Shopify卖家:EDM营销就要搭配SaleSmartly,轻松搞定转化率
随机推荐
无法一次粘贴多张图片
Machine learning based on deepchem
Environment configuration stepping pit during colab use
Anaconda offline installation environment
Beijing post network research 2015 problem2
for_ Example of each usage
Simple understanding of CDN, SDN and QoS
What have I learned from 200 machine learning tools?
数字孪生实际应用案例-智慧能源篇
Tonight at 7:30 | is the AI world in the eyes of Lianjie, Jiangmen, Baidu and country garden venture capital continue to be advanced or return to the essence of business
最新二开版漫画小说听书三合一完整源码/整合免签接口/搭建教程/带采集接口
座机的表单验证
(codeforce547)C-Mike and Foam(质因子+容斥原理)
Raft protocol - process demonstration
Deep into C language (1) -- operators and expressions
Simple use of eventbus
Instance setup flask service (simple version)
I.MX6U-驱动开发-2-LED驱动
CUB_200鸟类数据集关键点可视化
【redis系列】字符串数据结构