From 3525d3d86aab16b7b5d096d5959df88c13554608 Mon Sep 17 00:00:00 2001 From: BreakWa11 Date: Sun, 24 Jul 2016 23:06:54 +0800 Subject: [PATCH] fix get node_id --- db_transfer.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/db_transfer.py b/db_transfer.py index dbb0427..ae7a134 100644 --- a/db_transfer.py +++ b/db_transfer.py @@ -413,17 +413,21 @@ class Dbv3Transfer(DbTransfer): cur = conn.cursor() - cur.execute("SELECT `traffic_rate` FROM ss_node where `id`='" + str(self.cfg["node_id"]) + "'") + node_info_keys = ['traffic_rate'] + cur.execute("SELECT " + ','.join(node_info_keys) +" FROM ss_node where `id`='" + str(self.cfg["node_id"]) + "'") nodeinfo = cur.fetchone() - if nodeinfo == None : + if nodeinfo == None: rows = [] cur.close() conn.commit() return rows cur.close() - self.cfg['transfer_mul'] = float(nodeinfo['traffic_rate']) + node_info_dict = {} + for column in range(len(nodeinfo)): + node_info_dict[node_info_keys[column]] = r[column] + self.cfg['transfer_mul'] = float(node_info_dict['traffic_rate']) cur = conn.cursor() cur.execute("SELECT " + ','.join(keys) + " FROM user")