dgw / sopel-admindb

Allow bot admins to run SQL queries directly against the (willie-based) bot's database
0 stars 0 forks source link

[idea] Let other modules hook in and run their own custom queries #3

Closed dgw closed 6 years ago

dgw commented 8 years ago

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:

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…

dgw commented 6 years ago

This is unnecessary. bot.db.execute() already allows running arbitrary SQL. https://sopel.chat/docs/db.html#sopel.db.SopelDB.execute