def quotes(self): QtGui.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.WaitCursor)) conn = sqlite3.connect('HSAsserts.db') cursor = conn.cursor() stocks='' #select c.Code,TradeMarket from b_code c where c.Enable=1 and c.TradeMarket notnull for row in cursor.execute("select c.Code,TradeMarket from b_code c,v_assets a where c.Enable=1 and c.TradeMarket notnull and a.code= c.code and a.sumvollum !=0 "): if( stocks == ''): stocks = row[1].lower() + row[0] else: stocks = stocks + ',' + row[1].lower()+row[0] qd = SinaQuote.GetQuote( stocks ) #print(qd) sql = "INSERT OR REPLACE INTO D_LatestQuote VALUES (?, ?, ?)" for i in range( len(qd) ): CValue = qd.iloc[i]['C'] if CValue == 0: CValue = qd.iloc[i]['PC'] sqltuple = (qd.iloc[i]['code'][2:] , qd.iloc[i]['datetime'].strftime('%Y-%m-%d %H:%M:%S'), str(CValue) ) cursor.execute(sql,sqltuple) conn.commit() conn.close() QtGui.QApplication.restoreOverrideCursor() QtGui.QMessageBox.information(self,self.tr('Get Quotes'), self.tr('[{0}] records updated.'.format(i)) , QtGui.QMessageBox.Ok)