Pool Database Connections #27

Closed
opened 1 week ago by VD15 · 0 comments
VD15 commented 1 week ago
Collaborator

Database functions currently create a unique connection for every transaction: d9027356ab/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 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 1 week ago
VD15 self-assigned this 1 week ago
VD15 added reference 27_pool_db_connections 1 week ago
VD15 closed this issue 1 week ago
VD15 added this to the v1.1 milestone 1 week ago
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: waifu/kemoverse#27
Loading…
There is no content yet.