from __future__ import print_function from pymysql import err import sql import util def get_batch(connection, limit, offset): try: with connection.cursor() as cursor: cursor.execute(sql.GET_BATCH, {'limit': limit, 'offset': offset}) result = cursor.fetchall() return result except err.MySQLError as ex: print('error ' + str(ex)) @util.retry(retry_count=3) def update_report(connection, records): with connection.cursor() as cursor: for record in records: cursor.execute(sql.UPDATE_REPORT, record) connection.commit()