Here is a sample using Text::SimpleTable with DBIx::Class. This isn't abstract enough. It should take the column names from the DB, the sizes from the max output record v max allowed, etc, etc. Still, it's fun and I might like to use it myself sometime so I post it here where I'll be able to find it again. It's not super short so <readmore/> it is-

Text::SimpleTable + DBIC code

use warnings; use strict; use Text::SimpleTable; use Data::Random qw( rand_words rand_datetime ); # use My::Schema; <-- See BEGIN block below. # Assumes a terminal 80 chars wide (table is self-padding), Term::Size # or similar and $SIG{WINCH} could be used to make it dynamic and flui +d. my $table = Text::SimpleTable->new( [ 3, "Id" ], [ 15, "Stuff" ], [ 30, "Junk" ], [ 19, "Created" ], ); my $schema = My::Schema->connect("dbi:SQLite::memory:", undef, undef, { sqlite_use_immediate_transaction => + 1, RaiseError => 1, AutoCommit => 1, }); $schema->deploy; for ( 1 .. int(1+rand(10)) ) { $schema->resultset("Thingy")->create({ stuff => ucfirst(join(" ", rand_words( min => 1, max => 3 ))), junk => ucfirst(join(" ", rand_words( min => 5, max => 15 ))) +. ".", created => rand_datetime(), }); } my $rs = $schema->resultset("Thingy")->search; while ( my $thingy = $rs->next ) { $table->row( $thingy->id, $thingy->stuff, $thingy->junk, $thingy-> +created ); } print $table->draw; exit; BEGIN { package My::Schema::Thingy; use strict; use warnings; use parent "DBIx::Class::Core"; __PACKAGE__->table("thingy"); __PACKAGE__->add_columns( "id", { data_type => "INT", default_value => undef, extra => { unsigned => 1 }, is_auto_increment => 1, is_nullable => 0, size => 10, }, "stuff", { data_type => "MEDIUMTEXT", default_value => undef, is_nullable => 0, size => 16777215, }, "junk", { data_type => "MEDIUMTEXT", default_value => undef, is_nullable => 0, size => 16777215, }, "created", { data_type => "DATETIME", default_value => undef, is_nullable => 0, size => 19, }, ); __PACKAGE__->set_primary_key("id"); package My::Schema; use strict; use warnings; use parent "DBIx::Class::Schema"; __PACKAGE__->load_classes(qw( Thingy )); }

Sample output

.-----+-----------------+--------------------------------+------------ +---------. | Id | Stuff | Junk | Created + | +-----+-----------------+--------------------------------+------------ +---------+ | 1 | Smartest | Salt distractions perch botch- | 2011-06-01 +07:46:20 | | | | ed alundum cow memoirs. | + | | 2 | Reproducibly | Hinduism thirtieth pickers Ta- | 2011-01-07 +03:47:29 | | | | rbell Sartre sextet athlete p- | + | | | | opcorn complain Melinda syste- | + | | | | matizes bans discretely apoca- | + | | | | lyptic. | + | | 3 | Placental stai- | Formidable faraway Schantz Vi- | 2010-12-31 +20:53:27 | | | ning dozenth | vian starve handkerchief alte- | + | | | | rnating expended imperfection- | + | | | | criticisms newlywed. | + | | 4 | Duplicators | Administratively Christianize- | 2011-10-10 +10:22:10 | | | | s Almaden tired mendacity Tem- | + | | | | pleton May Molochizes prison - | + | | | | limitability scarce singly Ka- | + | | | | therine preparatives bimetall- | + | | | | ism. | + | | 5 | Grievously | Compilation dioxide intoxicat- | 2011-07-22 +07:16:40 | | | | ed humoring Andorra Siberian - | + | | | | speared recruit Sioux love re- | + | | | | penting. | + | | 6 | Latinizer | Passivate adhesive violators - | 2011-04-09 +10:14:11 | | | | unbound guy incorrectly brimf- | + | | | | ul. | + | '-----+-----------------+--------------------------------+------------ +---------'
</readmore

In reply to Re: display database records at the console by Your Mother
in thread display database records at the console by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.