django中有没有连接池
2022/4/26 23:47:44
本文主要是介绍django中有没有连接池,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
没有,django中一个请求就会创建一个mysql连接,django并发量不高,mysql能撑住
在django中使用连接池
参考网址
https://pypi.org/project/django-db-connection-pool/
安装
pip install django-db-connection-pool
修改Django的配置文件
# change django.db.backends.mysql to dj_db_conn_pool.backends.mysql: DATABASES = { 'default': { ... 'ENGINE': 'dj_db_conn_pool.backends.mysql' ... } }
连接池选项
# 方式一: DATABASES = { 'default': { ... 'POOL_OPTIONS' : { 'POOL_SIZE': 10, 'MAX_OVERFLOW': 10 } ... } } # 方式二: import dj_db_conn_pool dj_db_conn_pool.setup(pool_size=100, max_overflow=50)
这篇关于django中有没有连接池的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-04-01got an unexpected keyword argument
- 2024-03-30维多利亚的秘密 golang入坑系统
- 2024-03-29mongodb sort by date
- 2024-03-29go swagger
- 2024-03-25mongodb cdc
- 2024-03-25how to use go in vscode
- 2024-03-22mongooseserverselectionerror: connect econnrefused ::1:27017
- 2024-03-21pymongo insert_many
- 2024-03-18projection mongodb
- 2024-03-14clickhouse-go