Change the column data delimiter on mysqldump output
Question: I'm looking to change to formatting of the output produced by the mysqldump
command in the following way:

    
    
    (data_val1,data_val2,data_val3,...)
    

to

    
    
    (data_val1|data_val2|data_val3|...)
    

The change here being a different delimiter. This would then allow me to (in
python) parse the data lines using a line.split("|") command and end up with
the values correctly split (as opposed to doing line.split(",") and have
values that contain commas be split into multiple values).

I've tried using the --fields-terminated-by flag, but this requires the --tab
flag to be used as well. I don't want use the --tab flag as it splits the dump
into several files. Does anyone know how to alter the delimiter that mysqldump
uses?


Answer: This is not a good idea. Instead of using `string.split()` in Python, use [the
`csv` module](http://docs.python.org/library/csv.html) to properly parse CSV
data, which may be enclosed in quotes and may have internal `,` which aren't
delimiters.

    
    
    import csv
    

MySQL dump files are intended to be used as input back into MySQL. If you
really want pipe-delimited output, use the [`SELECT INTO OUTFILE`
syntax](http://dev.mysql.com/doc/refman/5.0/en/select.html) instead with the
`FIELDS TERMINATED BY '|'` option.

