Pool Database Connections #27

Closed
opened 2025-05-24 16:05:00 -07:00 by VD15 · 0 comments
Collaborator

Database functions currently create a unique connection for every transaction:

conn = get_db_connection()

In addition to code duplication, this has a significant overhead and could lead to performance issues. We can instead start one connection to the database on application startup and share it between all database functions via a global variable.

The database connection can also be set to enable autocommit to further cut down on redundant code.

Database functions currently create a unique connection for every transaction: https://git.waifuism.life/waifu/kemoverse/src/commit/d9027356abeba6983f7bc71b7320730060a97f9b/bot/db_utils.py#L15 In addition to code duplication, this has a significant overhead and could lead to performance issues. We can instead start one connection to the database on application startup and share it between all database functions via a global variable. The database connection can also be set to enable [autocommit](https://docs.python.org/3/library/sqlite3.html#sqlite3.connect) to further cut down on redundant code.
VD15 added this to the v1.1 project 2025-05-24 16:05:01 -07:00
VD15 self-assigned this 2025-05-26 03:27:37 -07:00
VD15 added reference 27_pool_db_connections 2025-05-26 04:52:14 -07:00
VD15 closed this issue 2025-05-26 05:25:12 -07:00
VD15 added this to the v1.1 milestone 2025-05-26 08:28:58 -07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: waifu/kemoverse#27
No description provided.