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.
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.