func PrettyPrintSQLColsRows()

in go/utils.go [208:239]


func PrettyPrintSQLColsRows(rows *sql.Rows, style string, render string, page int) {
	t := table.NewWriter()
	t.SetOutputMirror(os.Stdout)
	if rows == nil {
		return
	}
	columns, _ := rows.Columns()
	if columns != nil && len(columns) > 0 {
		myrow := make(table.Row, len(columns))
		for i, c := range columns {
			myrow[i] = c
		}
		t.AppendHeader(myrow)
	}
	for rows.Next() {
		rawResult := make([][]byte, len(columns))
		row := make([]interface{}, len(columns))
		for i := range rawResult {
			row[i] = &rawResult[i] // pointers to each string in the interface slice
		}
		// We don't consider malformed rows
		_ = rows.Scan(row...)
		s := make(table.Row, len(columns))
		for i, cell := range rawResult {
			s[i] = string(cell)
		}
		t.AppendRow(s)
	}
	t.SetPageSize(page)
	t.SetStyle(getTableStyle(style))
	renderTable(render, t)
}