From 42832a6dd143ad546cbcd046ecdb1a70656747ad Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Fri, 27 Sep 2013 09:51:51 +0200 Subject: [PATCH] Optimize by updating the column names when any query happens, only using a specific query when really necessary --- core/db.py | 2 ++ core/node.db | Bin 2048 -> 2048 bytes 2 files changed, 2 insertions(+) diff --git a/core/db.py b/core/db.py index b2b45fa..53272e5 100644 --- a/core/db.py +++ b/core/db.py @@ -169,6 +169,7 @@ class DatabaseTable(Table): return self._cache[key] except KeyError, e: result = self.db.query("SELECT * FROM %s WHERE `id` = ?" % self.table, params=(key,)) + self._set_column_names([x[0] for x in result.description]) if result is None: raise KeyError("No row with that ID was found in the table.") @@ -194,6 +195,7 @@ class MemoryTable(Table): def _retrieve_data(self): result = database.query("SELECT * FROM %s" % self.table) # Not SQLi-safe! + self._set_column_names([x[0] for x in result.description]) for row in result: row._nexus_db = self.db diff --git a/core/node.db b/core/node.db index 869792c7d9172353a6cad19a97f582a92014a233..9a4e018d94d0f022b4b4d5940850336933ad1398 100644 GIT binary patch delta 69 zcmZn=Xb_kn%_ulg#+gxYW5N<<2`*+Y2Ij}imzWPSZ(yF!+{awYoWmT=?6p~uMUPpK ZpPz$4SeTK4fgv#|IVCl%dU7=TQUFqa5Z3?z delta 52 zcmZn=Xb_kn%_uNY#+gxIW5N<DPd18aa I