From 301d3cb45adb687f924b176dd6b9840395b83d24 Mon Sep 17 00:00:00 2001 From: dngfx Date: Fri, 31 Aug 2018 05:48:53 +0100 Subject: Revert the god awful database edits I made and make ducks.py convert to int. Might be an idea to make a make_int function? --- Database.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'Database.py') diff --git a/Database.py b/Database.py index b9490af9..c315d801 100644 --- a/Database.py +++ b/Database.py @@ -112,24 +112,10 @@ class ServerSettings(Table): [server_id, setting.lower()]) class ChannelSettings(Table): - def jsonKeys2int(self, x): - if isinstance(x, dict): - hold = {} - for k, v in x.items(): - key = int(k) if k.isdigit() else k - val = int(v) if v.isdigit() else v - - hold[key] = val - return hold - else: - return x - def set(self, channel_id, setting, value): - converted_json = self.jsonKeys2int(value) - self.database.execute( "INSERT OR REPLACE INTO channel_settings VALUES (?, ?, ?)", - [channel_id, setting.lower(), converted_json]) + [channel_id, setting.lower(), json.dumps(value)]) def get(self, channel_id, setting, default=None): value = self.database.execute_fetchone( """SELECT value FROM channel_settings WHERE @@ -368,4 +354,4 @@ class Database(object): DELETE CASCADE, PRIMARY KEY (user_id, channel_id, setting))""") self.execute("""CREATE INDEX user_channel_settings_index - ON user_channel_settings (user_id, channel_id, setting)""") + ON user_channel_settings (user_id, channel_id, setting)""") \ No newline at end of file -- cgit v1.3.1-10-gc9f91