pub struct Settings {
pub format: Format,
pub header: bool,
pub separator: String,
pub newline: String,
pub nullvalue: String,
pub table: String,
}Expand description
Everything about how output is printed, which is what the dot commands change.
Fields§
§format: FormatThe output mode.
header: boolWhether to print the column names.
separator: StringWhat goes between two values in the separated modes.
newline: StringWhat goes between two rows in the separated modes.
nullvalue: StringWhat a null prints as in the modes that do not have a spelling of their own for it.
table: StringThe table name .mode insert puts in the statements it writes.
Implementations§
Source§impl Settings
impl Settings
Sourcepub fn set_format(&mut self, format: Format)
pub fn set_format(&mut self, format: Format)
Switches mode, resetting both separators to that mode’s defaults.
Resetting is DuckDB’s behaviour and it surprises people, so it is worth saying why it is
right: .mode csv means “write me a CSV”, and a pipe separator left over from an earlier
.mode list would produce a file that is not one. The header setting is deliberately left
alone, which is also DuckDB’s behaviour and was checked against the binary rather than
guessed, because .headers off is a thing somebody says once and expects to stay said.
Sourcepub fn set_format_flag(&mut self, format: Format)
pub fn set_format_flag(&mut self, format: Format)
Switches mode the way a command line flag does, which is not the way .mode does.
A flag sets the column separator and leaves the row separator alone. The difference shows up
in exactly one place and it is the one people pipe into other programs: duckdb -csv ends a
row with \n and duckdb -cmd ".mode csv" ends it with \r\n, on the same build, in the
same run. It looks like an oversight upstream and it is not ours to correct, because a script
written against duckdb -csv is a script whose next stage is counting bytes.
Checked against duckdb v2.0.0-dev84237 for -list, -csv and -ascii, which are the
flags that name a mode and reach this.