def fetch_and_delete_entities(database, table, schema, first_key, entities_only=False):
 backoff_timeout = 30
 batch_size = 1000
 last_key = ((first_key + '\x00') + TERMINATING_STRING)
 logging.debug('Deleting application data in the range: {0} - {1}'.format(first_key, last_key))
 db = DatastoreFactory.getDatastore(database)
 if (entities_only and (table == METADATA_TABLE)):
  return
 logging.info('Deleting data from {0}'.format(table))
 start_inclusive = True
 while True:
  try:
   entities = db.range_query(table, schema, first_key, last_key, batch_size, start_inclusive=start_inclusive)
   if (not entities):
    logging.info('No entities found for {}'.format(table))
    break
   for ii in entities:
    db.batch_delete(table, ii.keys())
   logging.info('Deleted {0} entities'.format(len(entities)))
   first_key = entities[(-1)].keys()[0]
   start_inclusive = False
  except AppScaleDBConnectionError:
   logging.exception('Error while deleting data')
   time.sleep(backoff_timeout)

def fetch_and_delete_entities ( database , table , schema , first_key , entities_only = False ) : backoff_timeout = 30 batch_size = 1000 last_key = ( ( first_key + '\x00' ) + TERMINATING_STRING ) logging . debug ( 'Deleting application data in the range: {0} - {1}' . format ( first_key , last_key ) ) db = DatastoreFactory . getDatastore ( database ) if ( entities_only and ( table == METADATA_TABLE ) ) : return logging . info ( 'Deleting data from {0}' . format ( table ) ) start_inclusive = True while True : try : entities = db . range_query ( table , schema , first_key , last_key , batch_size , start_inclusive = start_inclusive ) if ( not entities ) : logging . info ( 'No entities found for {}' . format ( table ) ) break for ii in entities : db . batch_delete ( table , ii . keys ( ) ) logging . info ( 'Deleted {0} entities' . format ( len ( entities ) ) ) first_key = entities [ ( - 1 ) ] . keys ( ) [ 0 ] start_inclusive = False except AppScaleDBConnectionError : logging . exception ( 'Error while deleting data' ) time . sleep ( backoff_timeout )
deletes all data from datastore .