Django Db Connection Pool

screenshot of Django Db Connection Pool
django

Django Db Connection Pool

Database connection pool component library for Django

Overview:

django-db-connection-pool is a connection pool component for Django that supports MySQL, Oracle, PostgreSQL, and JDBC (Oracle, OceanBase). It is based on SQLAlchemy and works well in multiprocessing and multithreading Django projects.

Features:

  • Connection pooling for MySQL, Oracle, PostgreSQL, and JDBC
  • Works in multiprocessing and multithreading Django projects
  • Can provide additional options for pool creation

Installation:

To install django-db-connection-pool, you can use pip. Here are the installation steps for different database engines:

Install with pip with all engines:

pip install django-db-connection-pool

Or select specific engines:

pip install "django-db-connection-pool[mysql]"
pip install "django-db-connection-pool[oracle]"
pip install "django-db-connection-pool[postgresql]"
pip install "django-db-connection-pool[jdbc]"

Update settings for each database engine:

  • MySQL: change django.db.backends.mysql to dj_db_conn_pool.backends.mysql
  • Oracle: change django.db.backends.oracle to dj_db_conn_pool.backends.oracle
  • PostgreSQL: change django.db.backends.postgresql to dj_db_conn_pool.backends.postgresql

(Optional) Pool options: You can provide additional options to pass to SQLAlchemy's pool creation by adding a key named POOL_OPTIONS to your settings. Here are the available options:

  • pool_size: The size of the pool to be maintained (default: 5)
  • max_overflow: The maximum overflow size of the pool (default: 10)
  • recycle: Number of seconds between connection recycling (default: -1)

Alternatively, you can use dj_db_conn_pool.setup to change default arguments for each pool's creation before using the database pool.

Summary:

django-db-connection-pool is a useful component for Django that enables connection pooling for various database engines. It works well in multiprocessing and multithreading environments and provides additional options for pool creation.

django
Django

Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. It follows the model-view-controller (MVC) architectural pattern, providing an extensive set of built-in tools and conventions to streamline the creation of robust and scalable web applications.

fullstack
Fullstack Boilerplates

A fullstack boilerplate provides a starter application that includes both frontend and backend. It should include database, auth, payments, user roles and other backend services to build a fully featured saas or webapps.