MCPcopy Create free account
hub / github.com/douglance/devsql / format_csv

Function format_csv

crates/vcsql/src/cli/output.rs:69–83  ·  view source on GitHub ↗
(result: &QueryResult, no_header: bool, writer: &mut W)

Source from the content-addressed store, hash-verified

67}
68
69fn format_csv<W: Write>(result: &QueryResult, no_header: bool, writer: &mut W) -> Result<()> {
70 let mut csv_writer = csv::Writer::from_writer(writer);
71
72 if !no_header {
73 csv_writer.write_record(&result.columns)?;
74 }
75
76 for row in &result.rows {
77 let string_row: Vec<String> = row.iter().map(value_to_string).collect();
78 csv_writer.write_record(&string_row)?;
79 }
80
81 csv_writer.flush()?;
82 Ok(())
83}
84
85fn value_to_string(value: &Value) -> String {
86 match value {

Callers 1

format_outputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected