MCPcopy Create free account
hub / github.com/RedisGraph/redisgraph-go / PrettyPrint

Method PrettyPrint

query_result.go:317–347  ·  view source on GitHub ↗

PrettyPrint prints the QueryResult to stdout, pretty-like.

()

Source from the content-addressed store, hash-verified

315
316// PrettyPrint prints the QueryResult to stdout, pretty-like.
317func (qr *QueryResult) PrettyPrint() {
318 if qr.Empty() {
319 return
320 }
321
322 table := tablewriter.NewWriter(os.Stdout)
323 table.SetAutoFormatHeaders(false)
324 table.SetHeader(qr.header.column_names)
325 row_count := len(qr.results)
326 col_count := len(qr.header.column_names)
327 if len(qr.results) > 0 {
328 // Convert to [][]string.
329 results := make([][]string, row_count)
330 for i, record := range qr.results {
331 results[i] = make([]string, col_count)
332 for j, elem := range record.Values() {
333 results[i][j] = fmt.Sprint(elem)
334 }
335 }
336 table.AppendBulk(results)
337 } else {
338 table.Append([]string{"No data returned."})
339 }
340 table.Render()
341
342 for k, v := range qr.statistics {
343 fmt.Fprintf(os.Stdout, "\n%s %f", k, v)
344 }
345
346 fmt.Fprintf(os.Stdout, "\n")
347}
348
349func (qr *QueryResult) LabelsAdded() int {
350 return int(qr.getStat(LABELS_ADDED))

Callers

nothing calls this directly

Calls 2

EmptyMethod · 0.95
ValuesMethod · 0.80

Tested by

no test coverage detected