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 fluid. 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 )); } #### .-----+-----------------+--------------------------------+---------------------. | 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. | | '-----+-----------------+--------------------------------+---------------------'