Исправлен код ''»Защиту get_day1_reports (соединение): курсор = connection.cursor () запрос =«выберите FILE_NAME, FILE_ITEM_COUNT как SENT_TO_CSG_COUNT, REJECT_COUNT, HSDC_TOTDO C как CSG_PROCESS_COUNT, FILE_CSG_MAILITEM_COUNT, FILE_STATUS, FILE_CREATE_DATE от RECON_HS_FILE_TRACKING где DateDiff ( curdate (), подстрока (FILE_NAME, 30,8)) = 2 "cursor.execute (запрос) data = cursor.fetchall () возвращаемые данные
класс Email_reports (): def init (self, settings): self.sender = settings.fromEmail self.recipient = settings.toEmail self.aws_region = settings.region self.charset = "UTF-8" context_opts = dict () self.logger = HSLogger ( имя , ** context_opts)
def write_to_default_ws_row_col(self,reports):
os.chdir('/tmp')
wb = Workbook(write_only=True)
report_ws = wb.create_sheet("Reports")
# write header
report_ws.append(["File Name", "CSG Sent Count", "Rject Count", "CSG Process Count", "File CSG Mailitem Count", "File Status", "File Create Date"])
# write data
for report in reports:
report_FILE_NAME = report[0]
report_FILE_ITEM_COUNT = report[1]
report_REJECT_COUNT = report[2]
report_HSDC_TOTDOC = report[3]
report_FILE_CSG_MAILITEM_COUNT = report[4]
report_FILE_STATUS = report[5]
report_FILE_CREATE_DATE = report[6]
report_ws.append([report_FILE_NAME, report_FILE_ITEM_COUNT, report_REJECT_COUNT, report_HSDC_TOTDOC, report_FILE_CSG_MAILITEM_COUNT, report_FILE_STATUS, report_FILE_CREATE_DATE])
# abspath = os.path.abspath(__file__)
# logger.info('abspath %s.', abspath)
# dname = os.path.dirname(abspath)
# logger.info('dname %s.', dname)
# os.chdir(dname)
# dirpath = os.getcwd()
# logger.info('current dir %s.', dirpath)
# contents = os.listdir("/tmp")
# logger.info('before save %s.', contents)
wb.save(filename = 'day1_reports.xlsx')
'' '