def add_cea(row): ign = row.get('ID_ADR') laposte = row.get('HEXACLE_1') if laposte == 'NR': return report('Missing CEA', ign, report.ERROR) query = HouseNumber.update(laposte=laposte).where(HouseNumber.ign == ign) done = query.execute() if not done: return report('IGN id not found', ign, report.ERROR) report('Done', ign, report.NOTICE)
def add_cea(row): ign = row.get('ID_ADR') laposte = row.get('HEXACLE_1') if laposte == 'NR': return report('Missing CEA', ign, report.ERROR) query = HouseNumber.update(laposte=laposte).where(HouseNumber.ign == ign) try: done = query.execute() except peewee.IntegrityError: report('Duplicate CEA', laposte, report.ERROR) else: if not done: return report('IGN id not found', ign, report.ERROR) report('Done', ign, report.NOTICE)