The bot.db system doesn't really allow for running custom queries against the bot's database, at least as far as I can see in the documentation. What if this module allowed not only bot owner/admins to run queries, but also other modules?
Considerations:
Would need more granular permissions management
Not clear how to let modules call each other, or if standard Python import statements would work as expected
Basically, there's a big question mark over the whole "how to implement" section
If it is doable, maybe it would even be possible to make this module a sort of wrapper for other modules that want to define custom tables. For example, dgw/willie-UnoBot#9 currently uses a file on disk to store score info (previously plain-text/TSV, now JSON). It would be better to have that in a custom table. (Can't put it in bot.db because (as investigations for dgw/willie-duel#1, dgw/willie-roulette#1, and dgw/willie-BombBot#11 have shown) there's no good way to query for leaderboard-type statistics AND resolve each entry to the correct nick. Custom database tables are probably the only way to solve this.
This might even turn into a general "dbutils" module, rather than "admindb", and I'd have to rename it—but that would put even more framework-type stuff in-scope, like managed module tables that reference the ID of a nick group but also have a canonical nick stored. Too bad bot.db.add_table() was removed last year…
The
bot.db
system doesn't really allow for running custom queries against the bot's database, at least as far as I can see in the documentation. What if this module allowed not only bot owner/admins to run queries, but also other modules?Considerations:
import
statements would work as expectedIf it is doable, maybe it would even be possible to make this module a sort of wrapper for other modules that want to define custom tables. For example, dgw/willie-UnoBot#9 currently uses a file on disk to store score info (previously plain-text/TSV, now JSON). It would be better to have that in a custom table. (Can't put it in
bot.db
because (as investigations for dgw/willie-duel#1, dgw/willie-roulette#1, and dgw/willie-BombBot#11 have shown) there's no good way to query for leaderboard-type statistics AND resolve each entry to the correct nick. Custom database tables are probably the only way to solve this.This might even turn into a general "dbutils" module, rather than "admindb", and I'd have to rename it—but that would put even more framework-type stuff in-scope, like managed module tables that reference the ID of a nick group but also have a canonical nick stored. Too bad
bot.db.add_table()
was removed last year…