Conveinience: Converts a tablename to csv format

    Args:
        tablename (str):
        exclude_columns (list):

    Returns:
        str: csv_table

    CommandLine:
        python -m ibeis.control.SQLDatabaseControl --test-get_table_csv

    Example:
        >>> # DISABLE_DOCTEST
        >>> from ibeis.control.SQLDatabaseControl import *  # NOQA
        >>> # build test data
        >>> import ibeis
        >>> ibs = ibeis.opendb('testdb1')
        >>> db = ibs.db
        >>> tablename = ibeis.const.NAME_TABLE
        >>> exclude_columns = []
        >>> # execute function
        >>> csv_table = db.get_table_csv(tablename, exclude_columns)
        >>> # verify results
        >>> result = str(csv_table)
        >>> print(result)

def get_table_csv(cur, tablename, exclude_columns=[]):
    """ Conveinience: Converts a tablename to csv format

    Args:
        tablename (str):
        exclude_columns (list):

    Returns:
        str: csv_table

    CommandLine:
        python -m ibeis.control.SQLDatabaseControl --test-get_table_csv

    Example:
        >>> # DISABLE_DOCTEST
        >>> from ibeis.control.SQLDatabaseControl import *  # NOQA
        >>> # build test data
        >>> import ibeis
        >>> ibs = ibeis.opendb('testdb1')
        >>> db = ibs.db
        >>> tablename = ibeis.const.NAME_TABLE
        >>> exclude_columns = []
        >>> # execute function
        >>> csv_table = db.get_table_csv(tablename, exclude_columns)
        >>> # verify results
        >>> result = str(csv_table)
        >>> print(result)
    """
    import utool as ut
    colnames_ = ut.get_table_columnname_list(cur, tablename)
    colnames = tuple([colname for colname in colnames_ if colname not in exclude_columns])
    row_list = ut.get_table_rows(cur, tablename, colnames, unpack=False)
    column_list = zip(*row_list)
    #=None, column_list=[], header='', column_type=None
    #import utool as ut
    #column_list, column_names = db.get_table_column_data(tablename, exclude_columns)
    # remove column prefix for more compact csvs
    column_lbls = [name.replace(tablename[:-1] + '_', '') for name in colnames]
    #header = db.get_table_csv_header(tablename)
    header = ''
    csv_table = ut.make_csv_table(column_list, column_lbls, header)
    return csv_table