Export a table to a CSV file.

        If an output path is provided, write to file. Else, return a
        string.

        Wrapper around pandas.sql.to_csv(). See:
        http://pandas.pydata.org/pandas-docs/stable/io.html#io-store-in-csv

        Arguments:

            table (str): Name of the table to export.
            output (str, optional): Path of the file to write.
            columns (str, optional): A comma separated list of columns
              to export.
            **kwargs: Additional args passed to pandas.sql.to_csv()

        Returns:

            str: CSV string, or None if writing to file.

        Raises:

            IOError: In case of error writing to file.
            SchemaError: If the named table is not found.

def export_csv(self, table, output=None, columns="*", **kwargs):
        """
        Export a table to a CSV file.

        If an output path is provided, write to file. Else, return a
        string.

        Wrapper around pandas.sql.to_csv(). See:
        http://pandas.pydata.org/pandas-docs/stable/io.html#io-store-in-csv

        Arguments:

            table (str): Name of the table to export.
            output (str, optional): Path of the file to write.
            columns (str, optional): A comma separated list of columns
              to export.
            **kwargs: Additional args passed to pandas.sql.to_csv()

        Returns:

            str: CSV string, or None if writing to file.

        Raises:

            IOError: In case of error writing to file.
            SchemaError: If the named table is not found.
        """
        import pandas.io.sql as panda

        # Determine if we're writing to a file or returning a string.
        isfile = output is not None
        output = output or StringIO()

        if table not in self.tables:
            raise SchemaError("Cannot find table '{table}'"
                              .format(table=table))

        # Don't print row indexes by default.
        if "index" not in kwargs:
            kwargs["index"] = False

        table = panda.read_sql("SELECT {columns} FROM {table}"
                               .format(columns=columns, table=table),
                               self.connection)
        table.to_csv(output, **kwargs)
        return None if isfile else output.getvalue()