import configServer as xCS import dbFunction as fD import pandas as pd import time import matplotlib.pyplot as plt start_time = time.time() fD.setConnection(typeConn='source', modeConnOnOff='on', connectionUse=xCS.connServ52_coreReport) res = fD.querySelect( typeConn='source', querySource='select msc, pool from do_msc group by msc, pool') dfDoMsc = pd.DataFrame() for rx in res: datax = {'msc': rx[0], 'pool': rx[1]} dfDoMsc = dfDoMsc.append(datax, ignore_index=True) fD.setConnection(typeConn='source', modeConnOnOff='off') #------------------------ dfUseKpi = pd.DataFrame() fD.setConnection(typeConn='source', modeConnOnOff='on', connectionUse=xCS.connServ52_neHuawei) res = fD.querySelect(typeConn='source', querySource=""" SELECT XDATE ,POOL ,NE
import configServer as xCS import dbFunction as fD import pandas as pd import time import matplotlib.pyplot as plt start_time = time.time() fD.setConnection(typeConn='source', modeConnOnOff='on', connectionUse=xCS.connServ52_coreReport) res = fD.querySelect( typeConn='source', querySource='select msc, pool from do_msc group by msc, pool') dfDoMsc = pd.DataFrame() for rx in res: datax = {'msc': rx[0], 'pool': rx[1]} dfDoMsc = dfDoMsc.append(datax, ignore_index=True) fD.setConnection(typeConn='source', modeConnOnOff='off') #------------------------ dfUseKpi = pd.DataFrame() # fD.setConnection(typeConn='source',modeConnOnOff='on',connectionUse= xCS.connServ52_neHuawei) # res = fD.querySelect(typeConn='source',querySource="select time, ne, attach, total from V_Kpi_HW_HR_RT where total > 0 and time >='2020-02-16'" ) # for rx in res: # datax = {'time': rx[0],'msc':rx[1], 'attach': rx[2], 'total': rx[3], 'system':'huawei'} # dfUseKpi = dfUseKpi.append(datax, ignore_index=True) # fD.setConnection(typeConn='source',modeConnOnOff='off') fD.setConnection(typeConn='target',
import configServer as xCS import dbFunction as fD import csv fD.setConnection(typeConn='source', modeConnOnOff='on', connectionUse=xCS.connServ103_neHuawei) for i in range(0, 2): for j in range(4, 7): StrQuery = "select * from tbl_Result_8388830" + str( i ) + " where ( [Result time] >='2020-0" + str( j ) + "-01' and [Result time] <'2020-0" + str( j + 1 ) + "-01' ) and ([object name] like '%818%' or [object name] like '%817%' or [object name] like '%838%')" # print(StrQuery) res = fD.querySelect(typeConn='source', querySource=StrQuery) with open('pm8388830' + str(i) + '_0' + str(j) + '.csv', 'w', newline='') as f_handle: fileOut = csv.writer(f_handle) fileOut.writerow("POOL,NE,DATE,ATTACH,DETECH,TOTAL".split(",")) for rx in res: fileOut.writerow(rx) fD.setConnection(typeConn='source', modeConnOnOff='off')