Documentation
¶
Overview ¶
Package output serializes query results into CLI-friendly formats.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LimitWriter ¶
LimitWriter wraps another writer and fails once the configured byte limit is exceeded. A non-positive Limit disables the guard and passes writes through.
type Result ¶
type Result struct {
Columns []string `json:"columns" yaml:"columns"`
Rows [][]interface{} `json:"rows" yaml:"rows"`
RowCount int `json:"row_count" yaml:"row_count"`
ElapsedMS int64 `json:"elapsed_ms" yaml:"elapsed_ms"`
}
Result is the database execution payload shared by output encoders. Columns is empty for statements that do not return rows, while RowCount and ElapsedMS still describe the completed operation.
type StreamWriter ¶
type StreamWriter struct {
// contains filtered or unexported fields
}
StreamWriter renders row results incrementally so callers do not need to keep the full result set in memory before writing output.
func NewStreamWriter ¶
func NewStreamWriter(w io.Writer, format string, columns []string, elapsedMS func() int64) (*StreamWriter, error)
NewStreamWriter starts an incremental result writer for row-returning queries.
func (*StreamWriter) Close ¶
func (sw *StreamWriter) Close() (Result, error)
Close finalizes output and returns the result summary.
func (*StreamWriter) RowCount ¶
func (sw *StreamWriter) RowCount() int
RowCount returns how many rows have been streamed so far.
func (*StreamWriter) WriteRow ¶
func (sw *StreamWriter) WriteRow(row []interface{}) error
WriteRow writes one result row.