Skip to content

Instantly share code, notes, and snippets.

@waltertschwe
Created June 24, 2019 20:32
Show Gist options
  • Select an option

  • Save waltertschwe/39fa708ae4bafab2aa8c5b6319471116 to your computer and use it in GitHub Desktop.

Select an option

Save waltertschwe/39fa708ae4bafab2aa8c5b6319471116 to your computer and use it in GitHub Desktop.
def import_fields(self, alerts):
residents = self.meta.tables['application_resident']
for alert in alerts:
resident = self.get_fields(alert)
query = residents.select((residents.c.resident_number == resident['resident_number']) & (residents.c.facility_id == resident['facility_id']))
hello = query.execute()
rows = hello.fetchall()
if not rows:
insert_stmt = insert(self.meta.tables['application_resident']).values(resident)
self.con.execute(insert_stmt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment