0
def SimplifyTrainUser(self):
self.cursor.execute('SELECT user_id, item_id, look, store, cart, buy FROM user_features limit 0, 50')
while True:
str=self.cursor.fetchone()
if str:
look_times = len(str['look'].split(',')) if str['look'] else 0
store_times = len(str['store'].split(',')) if str['store'] else 0
cart_times = len(str['cart'].split(',')) if str['cart'] else 0
buy_times = len(str['buy'].split(',')) if str['buy'] else 0
lru = max(str['look'].split(',') + str['store'].split(',') + str['cart'].split(',') + str['buy'].split(','))
user_id = str['user_id']
item_id = str['item_id']
if not (look_times <=4 and store_times <=1 and cart_times == 0 and buy_times == 0 and int(lru) <= 15):
self.cursor.execute('INSERT INTO pure_data VALUES(%s,%s,%s,%s,%s,%s)', (user_id, item_id, str['look'],
str['store'], str['cart'], str['buy']))
self.db.commit()
print "once"
global DELETE_INDEX
else:
return 0
self.cursor.execute('INSERT INTO pure_data VALUES(%s,%s,%s,%s,%s,%s)', (user_id, item_id, str['look'],str['store'], str['cart'], str['buy']))
只執行一次。如果我評論它,「一次」可以打印29次。是什麼原因?爲什麼cursor.execute只執行一次並在這種情況下返回?