original_docstring: 
          Returns a list of SQL statements required to remove all data from
          the given database tables (without actually removing the tables
          themselves).
  
          The returned value also includes SQL statements required to reset DB
          sequences passed in :param sequences:.
  
          The `style` argument is a Style object as returned by either
          color_style() or no_style() in django.core.management.color.
  
          The `allow_cascade` argument determines whether truncation may cascade
          to tables with foreign keys pointing the tables being truncated.
          
docstring: Returns a list of SQL statements required to remove all data from
  the given database tables (without actually removing the tables
  themselves).
  
  The returned value also includes SQL statements required to reset DB
  sequences passed in :param sequences:.
  
  The `style` argument is a Style object as returned by either
  color_style() or no_style() in django.core.management.color.
  
  The `allow_cascade` argument determines whether truncation may cascade
  to tables with foreign keys pointing the tables being truncated.
docstring_tokens: Returns a list of SQL statements required to remove all data from the given database tables ( without actually removing the tables themselves ) . The returned value also includes SQL statements required to reset DB sequences passed in : param sequences : . The ` style ` argument is a Style object as returned by either color_style () or no_style () in django . core . management . color . The ` allow_cascade ` argument determines whether truncation may cascade to tables with foreign keys pointing the tables being truncated .
code: def sql_flush(self, style, tables, sequences, allow_cascade=False):
          """
          Returns a list of SQL statements required to remove all data from
          the given database tables (without actually removing the tables
          themselves).
  
          The returned value also includes SQL statements required to reset DB
          sequences passed in :param sequences:.
  
          The `style` argument is a Style object as returned by either
          color_style() or no_style() in django.core.management.color.
  
          The `allow_cascade` argument determines whether truncation may cascade
          to tables with foreign keys pointing the tables being truncated.
          """
          if tables:
              # Cannot use TRUNCATE on tables that are referenced by a FOREIGN KEY
              # So must use the much slower DELETE
              from django.db import connections
              cursor = connections[self.connection.alias].cursor()
              # Try to minimize the risks of the braindeaded inconsistency in
              # DBCC CHEKIDENT(table, RESEED, n) behavior.
              seqs = []
              for seq in sequences:
                  cursor.execute("SELECT COUNT(*) FROM %s" % self.quote_name(seq["table"]))
                  rowcnt = cursor.fetchone()[0]
                  elem = {}
                  if rowcnt:
                      elem['start_id'] = 0
                  else:
                      elem['start_id'] = 1
                  elem.update(seq)
                  seqs.append(elem)
              cursor.execute("SELECT TABLE_NAME, CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_TYPE not in ('PRIMARY KEY','UNIQUE')")
              fks = cursor.fetchall()
              sql_list = ['ALTER TABLE %s NOCHECK CONSTRAINT %s;' % \
                      (self.quote_name(fk[0]), self.quote_name(fk[1])) for fk in fks]
              sql_list.extend(['%s %s %s;' % (style.SQL_KEYWORD('DELETE'), style.SQL_KEYWORD('FROM'),
                               style.SQL_FIELD(self.quote_name(table)) ) for table in tables])
  
              if self.connection.to_azure_sql_db and self.connection.sql_server_version < 2014:
                  warnings.warn("Resetting identity columns is not supported " \
                                "on this versios of Azure SQL Database.",
                                RuntimeWarning)
              else:
                  # Then reset the counters on each table.
                  sql_list.extend(['%s %s (%s, %s, %s) %s %s;' % (
                      style.SQL_KEYWORD('DBCC'),
                      style.SQL_KEYWORD('CHECKIDENT'),
                      style.SQL_FIELD(self.quote_name(seq["table"])),
                      style.SQL_KEYWORD('RESEED'),
                      style.SQL_FIELD('%d' % seq['start_id']),
                      style.SQL_KEYWORD('WITH'),
                      style.SQL_KEYWORD('NO_INFOMSGS'),
                      ) for seq in seqs])
  
              sql_list.extend(['ALTER TABLE %s CHECK CONSTRAINT %s;' % \
                      (self.quote_name(fk[0]), self.quote_name(fk[1])) for fk in fks])
              return sql_list
          else:
              return []
code_tokens: def sql_flush ( self , style , tables , sequences , allow_cascade = False ) : if tables : from django . db import connections cursor = connections [ self . connection . alias ] . cursor ( ) seqs = [ ] for seq in sequences : cursor . execute ( "SELECT COUNT(*) FROM %s" % self . quote_name ( seq [ "table" ] ) ) rowcnt = cursor . fetchone ( ) [ 0 ] elem = { } if rowcnt : elem [ 'start_id' ] = 0 else : elem [ 'start_id' ] = 1 elem . update ( seq ) seqs . append ( elem ) cursor . execute ( "SELECT TABLE_NAME, CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_TYPE not in ('PRIMARY KEY','UNIQUE')" ) fks = cursor . fetchall ( ) sql_list = [ 'ALTER TABLE %s NOCHECK CONSTRAINT %s;' % ( self . quote_name ( fk [ 0 ] ) , self . quote_name ( fk [ 1 ] ) ) for fk in fks ] sql_list . extend ( [ '%s %s %s;' % ( style . SQL_KEYWORD ( 'DELETE' ) , style . SQL_KEYWORD ( 'FROM' ) , style . SQL_FIELD ( self . quote_name ( table ) ) ) for table in tables ] ) if self . connection . to_azure_sql_db and self . connection . sql_server_version < 2014 : warnings . warn ( "Resetting identity columns is not supported " "on this versios of Azure SQL Database." , RuntimeWarning ) else : sql_list . extend ( [ '%s %s (%s, %s, %s) %s %s;' % ( style . SQL_KEYWORD ( 'DBCC' ) , style . SQL_KEYWORD ( 'CHECKIDENT' ) , style . SQL_FIELD ( self . quote_name ( seq [ "table" ] ) ) , style . SQL_KEYWORD ( 'RESEED' ) , style . SQL_FIELD ( '%d' % seq [ 'start_id' ] ) , style . SQL_KEYWORD ( 'WITH' ) , style . SQL_KEYWORD ( 'NO_INFOMSGS' ) , ) for seq in seqs ] ) sql_list . extend ( [ 'ALTER TABLE %s CHECK CONSTRAINT %s;' % ( self . quote_name ( fk [ 0 ] ) , self . quote_name ( fk [ 1 ] ) ) for fk in fks ] ) return sql_list else : return [ ]
short_docstring: Returns a list of SQL statements required to remove all data from
  the given database tables (without actually removing the tables
  themselves).
short_docstring_tokens: Returns a list of SQL statements required to remove all data from the given database tables ( without actually removing the tables themselves ) .
comment: """
          Returns a list of SQL statements required to remove all data from
          the given database tables (without actually removing the tables
          themselves).
  
          The returned value also includes SQL statements required to reset DB
          sequences passed in :param sequences:.
  
          The `style` argument is a Style object as returned by either
          color_style() or no_style() in django.core.management.color.
  
          The `allow_cascade` argument determines whether truncation may cascade
          to tables with foreign keys pointing the tables being truncated.
          """$SEP$# Cannot use TRUNCATE on tables that are referenced by a FOREIGN KEY$SEP$# So must use the much slower DELETE$SEP$# Try to minimize the risks of the braindeaded inconsistency in$SEP$# DBCC CHEKIDENT(table, RESEED, n) behavior.$SEP$# Then reset the counters on each table.