DeadbearBot icon indicating copy to clipboard operation
DeadbearBot copied to clipboard

Reformat db.py and associated calls

Open atbrandt opened this issue 3 years ago • 0 comments

Currently, the db calls are structured in such a way that each time a new db request is needed, an entire new function must be written to support the call, in spite of the fact that most of the calls execute in the exact same way (create connection, create cursor, import some pre-written sql, execute the sql, commit changes, close connection). This is wasteful and creates an excessively long file to read. Where possible, the db.py should be restructured so that the sql chunks are split out from the code and contained inside a resource file, with header lines that help python find the right chunk of code to import. The functions that share identical code can then be condensed into one generic function that takes in a reference header to define which sql to execute, and all of the necessary arguments in a wildcard format that can then be broken out into the individual variables needed for the sql.

atbrandt avatar Nov 30 '20 14:11 atbrandt