当前位置:网站首页>19. Optimized database query of tornado project
19. Optimized database query of tornado project
2022-06-12 03:41:00 【Solitary cold person】
The project has been basically completed , This article will optimize the database query in the project .
Review the project , stay /utils/account.py The file contains many query operations for the database , These database query operations all rely on session, This session From the modles/account.py from modles/db.py The DBsession Instantiation .
So how to optimize it ?
About database related operations , It is obvious that a large number of database related operations will occur after the user logs in , Moreover, the user authentication function was added after the user login function was realized .
So based on this , Optimization has a direction , We can authenticate users ( namely main.py Medium AuthBaseHandler class ) At the same time, connect and close the database .
see 【tornado Official Chinese documents 】, We found the implementation method in the following screenshot , Know our user authentication AuthBaseHandler Class also inherits RequestHandler class ! So we add the following to the user authentication class 3 and 5 Two methods , Automatically establish and close the connection to the database !
1. restructure session Use
- ReuestHandler Of prepare and on_finish Use :
class 边栏推荐
- 双目标定学习资料整理
- Computer configuration suggestions for learning modeling
- Unity脚本出現missing時的解决方法
- Sed command
- [mysql][mysql 8.0 compressed package installation method]
- JSP implementation of bank counter business performance evaluation system
- 1186_ Accumulation of embedded hardware knowledge_ Triode and three electrodes
- How do I make the mouse wheel work in the VB6 ide- How can I make mousewheel work in VB6 IDE?
- mysql/oracle 以唯一时间为分界,小于等于该时间求和,大于该时间求和
- FOB,CIF,CFR的区别是什么?
猜你喜欢

Unity脚本出現missing時的解决方法

顺序表与链表-----进阶

Review of technical economy and Enterprise Management Chapter 4

Sequence list and linked list - primary level

Mysql/oracle takes the unique time as the boundary, and the sum is less than or equal to this time, and greater than this time

tcp 三次握手与四次挥手

What is the core of Web3?

Mosaïque d'images basée sur la matrice de transformation

Three ways for ORALCE to process column to row conversion and finally generate table style data

MongoDB精华总结
随机推荐
2020-12-10
The rise of another domestic mobile phone chip is close to the height reached by Huawei
2020-12-17
消息队列概述
The road of global evolution of vivo global mall -- multilingual solution
PostMessage implements window communication
hash function
Functions (arguments, formal parameters, bubbling)
2020-12-12
R语言write函数:使用write函数将数据写入RStudio控制台、write函数将数据写入新的Rstudio窗口(启动新的窗口)
Infinite loop judgment method;
分數大小的比較
Kotlin协程协程作用域,CoroutineScope MainScope GlobalScope viewModelScope lifecycleScope 分别代表什么
TCP three handshakes and four waves
[Business Research Report] the salary growth rate report of each industry in 2022 includes regional growth rate - download link is attached
电商中台系统架构
[Hongmeng] use the timer to play a simple game of robbing red envelopes
Convert py file to EXE file
MySQL create user and authorize
根据变换矩阵进行图像拼接
