def __sum_main(self,datestr,list,sql_select,argss,min_count,array_re, sql_insert):
        tmp_cnt_col = 0
        for mn in list:
            tmp = []
            tmp.append(datestr)
            tmp.append(mn)
            for i in xrange(len(argss)):
                tmp.append(argss[i])
            tmp_1 = tuple(tmp)
            self.__sqlite_cursor.execute(sql_select, tmp_1)
            rows = self.__sqlite_cursor.fetchall()
            if (min_count >= len(rows)):
                self.__sqlite_logger.error("%(a)s:less than %(b)i data!continue." % {'a':mn,'b':min_count})
                tmp_cnt_col = tmp_cnt_col + 1
                continue
            self.__sqlite_logger.debug("%(con)s : %(len)i" % {'con':str(mn),'len':len(rows)})

            ## assign list to np.array
            list_data = np.array(rows)
            tmp_a = trinity(list_data) # mktvital4datestr
            for i in xrange(3):
                array_re[tmp_cnt_col,i] = tmp_a[i]
            tmp_cnt_col = tmp_cnt_col + 1
            
            try:
                self.__sqlite_cursor.execute(sql_insert,(datestr,mn,tmp_a[0],tmp_a[2],tmp_a[1]))
            except sqlite3.Error as err:
                self.__sqlite_logger.error("mktvital might shift insertion failed:%(con)s,%(arg)s" % {'con':mn, 'arg':err.args[0]})

        self.__sqlite_conn.commit()   
    def __5_sumup_main(self,datestr):
        tmp_cnt_col = 0        
        for mn in self.list_main:
            # print((datestr,mn))
            self.__sqlite_cursor.execute(sql_jzt_main,(datestr,mn))
            rows = self.__sqlite_cursor.fetchall() # mkt4datestr
            if (100 >= len(rows)):
                self.__sqlite_logger.error("%s: less than 100 data!return!" % mn)
                tmp_cnt_col = tmp_cnt_col + 1
                continue
            self.__sqlite_logger.debug("%(con)s : %(len)i" % {'con':str(mn),'len':len(rows)})

            ## assign list to np.array
            list_data = np.array(rows)
            tmp_a = trinity(list_data) # mktvital4datestr

            self.array_main_re[tmp_cnt_col,0] = tmp_a[0]
            self.array_main_re[tmp_cnt_col,1] = tmp_a[1]
            self.array_main_re[tmp_cnt_col,2] = tmp_a[2]
            tmp_cnt_col = tmp_cnt_col + 1 # BLANK may exists in self.array_main_re, but not in db

            try:
                self.__sqlite_cursor.execute(sql_jzt_mktvital_insert,(datestr,mn,tmp_a[0],tmp_a[2],tmp_a[1]))
            except sqlite3.Error as err:
                self.__sqlite_logger.error("mktvital insertion failed:%(con)s,%(arg)s" % {'con':mn, 'arg':err.args[0]})

        self.__sqlite_conn.commit()   
示例#3
0
        continu = my_str(continu)
        sqlite_cursor.execute(sql_jzt_continu,(datestr,continu))
        rows = sqlite_cursor.fetchall()
        # if (len_continu_row != len(rows)):
        #     print "wrong rows!%s" % continu
        #     tmp_cnt_col = tmp_cnt_col + 1
        #     continue
        print("%(con)s : %(len)i" % {'con':str(continu),'len':len(rows)})
        list_continu_data = np.zeros((len(rows),4))
        tmp_cnt_row = 0
        for row in rows:
            for i in xrange(4):
                list_continu_data[tmp_cnt_row,i] = row[i]
                # array_continu[tmp_cnt_row,tmp_cnt_col] = row[0]
            tmp_cnt_row = tmp_cnt_row + 1
        tmp_a = trinity(list_continu_data)
        print tmp_a
        list_continu_re1[tmp_cnt_col,0] = tmp_a[0]
        list_continu_re1[tmp_cnt_col,1] = tmp_a[1]
        list_continu_re1[tmp_cnt_col,2] = tmp_a[2]
        tmp_cnt_col = tmp_cnt_col + 1

        try:
            sqlite_cursor.execute(sql_jzt_mktvital_insert,(datestr,continu,tmp_a[0],tmp_a[2],tmp_a[1]))
        except sqlite3.Error as err:
            sqlite_logger.error("mktvital insertion failed:%(con)s,%(arg)s" % {'con':continu, 'arg':err.args[0]})
        sqlite_conn.commit()
    # corr_matrix = my_corr_matrix(array_continu)
    # print corr_matrix
    # heatmap(corr_matrix)
    # plt.show()