def dump(relation):
    width, height = term_size()
    table = Texttable(width)

    sample, iterator = tee(relation)

    table.add_rows(take(1000, sample))
    table._compute_cols_width()
    del sample

    table.reset()

    table.set_deco(Texttable.HEADER)
    table.header([f.name for f in relation.schema.fields])

    rows = take(height - 3, iterator)

    try:
        while rows:
            table.add_rows(rows, header=False)
            print table.draw()
            rows = take(height - 3, iterator)
            if rows:
                raw_input("-- enter for more ^c to quit --")
    except KeyboardInterrupt:
        print
def dump(relation):
  width,height = term_size()
  table = Texttable(width)


  sample, iterator = tee(relation)


  table.add_rows(take(1000,sample))
  table._compute_cols_width()
  del sample
  
  table.reset()

  table.set_deco(Texttable.HEADER)
  table.header([f.name for f in relation.schema.fields])



  rows = take(height-3, iterator)

  try:
    while rows:
      table.add_rows(rows, header=False)
      print table.draw()
      rows = take(height-3, iterator)
      if rows:
        raw_input("-- enter for more ^c to quit --")
  except KeyboardInterrupt:
    print