示例#1
0
    def insert(self, datas):

        j = len(datas)
        for i in range(0, j - 1):
            data=datas[i].split(",")

            db = DB()
            s_month=data[0][:7].replace("-","")
            sql = "select count(*) from sgba_ods_wb_kpi where kpi_month = '"+s_month+"' and kpi_code='M2'"
            db.execute(sql)
            results = db.fetchone()
            if results[0] == 0:
                kpi_id =  time.strftime("%Y%m%d%H%M%S", time.localtime()) + str(random.randint(100000,999999))
                sql = "INSERT INTO SGBA_ODS_WB_KPI(kpi_id,KPI_MONTH,KPI_CODE,KPI_NAME,KPI_DATA,KPI_TB,KPI_HB) VALUES("+kpi_id +"," + s_month  +",'M2','货币和准货币(M2)',"+ data[1] +","+ data[2] +","+ data[3] +")"
                db.execute(sql)
                db.commit()
            else:
                db.close()
                break
            sql = "select count(*) from sgba_ods_wb_kpi where kpi_month = '"+s_month+"' and kpi_code='M1'"
            db.execute(sql)
            results = db.fetchone()
            if results[0] == 0:
                kpi_id =  time.strftime("%Y%m%d%H%M%S", time.localtime()) + str(random.randint(100000,999999))
                sql = "INSERT INTO SGBA_ODS_WB_KPI(kpi_id,KPI_MONTH,KPI_CODE,KPI_NAME,KPI_DATA,KPI_TB,KPI_HB) VALUES("+kpi_id +"," + s_month +",'M1','货币(M1)',"+ data[4] +","+ data[5] +","+ data[6] +")"
                db.execute(sql)
                db.commit()
            sql = "select count(*) from sgba_ods_wb_kpi where kpi_month = '"+s_month+"' and kpi_code='M0'"
            db.execute(sql)
            results = db.fetchone()
            if results[0] == 0:
                kpi_id =  time.strftime("%Y%m%d%H%M%S", time.localtime()) + str(random.randint(100000,999999))
                sql = "INSERT INTO SGBA_ODS_WB_KPI(kpi_id,KPI_MONTH,KPI_CODE,KPI_NAME,KPI_DATA,KPI_TB,KPI_HB) VALUES("+kpi_id +"," + s_month  +",'M0','流通中的现金(M0)',"+ data[7] +","+ data[8] +","+ data[9] +")"
                db.execute(sql)
                db.commit()
            db.close()
示例#2
0
 def insert_tkszs(self, data):
     db = DB()
     sql = "select count(*) from sgba_ods_wb_hl where hl_day = '" + data[
         0] + "' and hl_code='TKSZS'"
     db.execute(sql)
     results = db.fetchone()
     if results[0] == 0:
         hl_id = time.strftime("%Y%m%d%H%M%S", time.localtime()) + str(
             random.randint(100000, 999999))
         sql = "INSERT INTO SGBA_ODS_WB_hl(HL_ID,HL_DAY,HL_CODE,HL_NAME,HL_DATA) VALUES(" + hl_id + "," + data[
             0] + ",'TKSZS','62%铁矿石普氏'," + data[1] + ")"
         db.execute(sql)
         db.commit()
     db.close()
示例#3
0
 def insert(self, data):
     db = DB()
     dt = datetime.now()
     ltime = time.localtime(data['f86'])
     datestr = time.strftime("%Y%m%d", ltime)
     if datestr != dt.strftime("%Y%m%d"):
         pass
     GP_ID = time.strftime("%Y%m%d%H%M%S", ltime) + str(
         random.randint(100000, 999999))
     sql = "delete from SGBA_ODS_WB_GP where gp_day = '" + datestr + "' and gp_code = '" + str(
         data['f57']) + "'"
     db.execute(sql)
     db.commit()
     sql = "INSERT INTO SGBA_ODS_WB_GP(GP_ID,GP_DAY,GP_CODE,GP_NAME,GP_ZSZ,GP_ZRSPJ,GP_JRKPJ,GP_JRZGJ,GP_JRZDJ,GP_SSJG) " \
           "VALUES('" +GP_ID+"','"+datestr+"','"+  str(data['f57'])+ "','" + str(data['f58']).replace("'","")+ "'," +str(data['f116'])+ "," +str(data['f60'])+ "," +str(data['f46'])+ "," +str(data['f44'])+ "," +str(data['f45'])+ "," +str(data['f43'])+ ")"
     db.execute(sql)
     db.commit()
     db.close()
示例#4
0
 def insert(self, code, name, data):
     db = DB()
     sql = "select count(*)  as cnt from sgba_ods_wb_kpi where kpi_month = '" + data[
         'date'] + "' and kpi_code='" + code + "'"
     db.execute(sql)
     results = db.fetchone()
     if results[0] == 0:
         kpi_id = time.strftime("%Y%m%d%H%M%S", time.localtime()) + str(
             random.randint(100000, 999999))
         sql = "INSERT INTO SGBA_ODS_WB_KPI(kpi_id,KPI_MONTH,KPI_CODE,KPI_NAME,KPI_DATA) VALUES('" + kpi_id + "','" + data[
             'date'] + "','" + code + "','" + name + "'," + data[
                 'strdata'] + ")"
         db.execute(sql)
         db.commit()
     db.close()
示例#5
0
 def insert(self, data):
     db = DB()
     dt = datetime.now()
     datestr = str(data['tradeDate'])
     if datestr != dt.strftime('%Y%m%d'):
         pass
     sql = "delete from SGBA_ODS_WB_QH where qh_day = '" + datestr + "' and qh_code ='" + data[
         'indexCode'] + "'"
     db.execute(sql)
     db.commit()
     qh_id = time.strftime("%Y%m%d%H%M%S", time.localtime()) + str(
         random.randint(100000, 999999))
     sql = "INSERT INTO SGBA_ODS_WB_QH(QH_ID,QH_DAY,QH_CODE,QH_NAME,QH_KP,QH_ZG,QH_ZD,QH_ZX,QH_ZDS,QH_ZDF,QH_SP,QH_JS,QH_ZSP,QH_ZJS) " \
           "VALUES("+qh_id +","  +datestr+",'"+ data['indexCode']+"','"+data['indexName']+"',"+data['openPrice']+","+data['highPrice']+","+data['lowPrice']+","+data['lastPrice']+","+data['netChange']+","+data['chgPercent'].replace("%","")+","+data['closePrice'].replace("--","0")+","+data['clearPrice'].replace("--","0")+","+data['lastClose']+","+data['lastClearPrice']+")"
     db.execute(sql)
     db.commit()
     db.close()
示例#6
0
 def insert(self, data):
     db = DB()
     dt = datetime.now()
     dtstr = dt.strftime('%Y%m%d')
     datestr = self.get_date()
     if dtstr != datestr :
         pass
     sql = "delete from SGBA_ODS_WB_QH where qh_day = '"+ datestr+"' and qh_code ='"+data['contractname']+"'"
     db.execute(sql)
     db.commit()
     qh_id =  time.strftime("%Y%m%d%H%M%S", time.localtime()) + str(random.randint(100000,999999))
     sql = "INSERT INTO SGBA_ODS_WB_QH(QH_ID,QH_DAY,QH_CODE,QH_NAME,QH_KP,QH_ZG,QH_ZD,QH_ZX,QH_ZDS,QH_ZJS) VALUES" \
           "("+qh_id +"," +dt.strftime('%Y%m%d')+",'"+ data['contractname']+"','螺纹钢"+data['contractname']+"',"+data['openprice'].replace("--","0")+","+data['highprice'].replace("--","0")+","+data['lowerprice'].replace("--","0")+","+data['lastprice']+","+data['upperdown']+","+data['presettlementprice']+")"
     db.execute(sql)
     db.commit()
     db.close()
示例#7
0
文件: shibor.py 项目: hikincn/python
 def insert(self, data):
     db = DB()
     sql = "select count(*) from sgba_ods_wb_hl where hl_day = '" + str(
         data[0]) + "' and hl_code='shibor'"
     db.execute(sql)
     results = db.fetchone()
     if results[0] == 0:
         hl_id = time.strftime("%Y%m%d%H%M%S", time.localtime()) + str(
             random.randint(100000, 999999))
         db.execute(
             "insert into SGBA_ODS_WB_HL(HL_ID,HL_DAY,HL_CODE,HL_NAME,HL_DATA) values('"
             + hl_id + "','" + str(data[0]) + "','shibor','隔夜利率(%) o/n'," +
             data[1] + ")")
         db.commit()
     db.close()