def _delete_calendar(db_session, calendar):
 count = 0
 for e in calendar.events:
  db_session.delete(e)
  count += 1
  if ((count % 100) == 0):
   db_session.commit()
 db_session.commit()
 db_session.delete(calendar)
 db_session.commit()

def _delete_calendar ( db_session , calendar ) : count = 0 for e in calendar . events : db_session . delete ( e ) count += 1 if ( ( count % 100 ) == 0 ) : db_session . commit ( ) db_session . commit ( ) db_session . delete ( calendar ) db_session . commit ( )
delete the calendar after deleting its events in batches .