def to_archive(self, writer):
if '<STR_LIT:b>' not in writer.mode:<EOL><INDENT>raise GiraffeError("<STR_LIT>")<EOL><DEDENT>writer.write(GIRAFFE_MAGIC)<EOL>writer.write(self.columns.serialize())<EOL>i = <NUM_LIT:0><EOL>for n, chunk in enumerate(self._fetchall(ROW_ENCODING_RAW), <NUM_LIT:1>):<EOL><INDENT>writer.write(chunk)<EOL>yield TeradataEncoder.count(chunk)<EOL><DEDENT>
Writes export archive files in the Giraffez archive format.
This takes a `giraffez.io.Writer` and writes archive chunks to
file until all rows for a given statement have been exhausted.

.. code-block:: python

    with giraffez.BulkExport("database.table_name") as export:
        with giraffez.Writer("database.table_name.tar.gz", 'wb', use_gzip=True) as out:
            for n in export.to_archive(out):
                print("Rows: {}".format(n))

:param `giraffez.io.Writer` writer: A writer handling the archive output

:rtype: iterator (yields ``int``)