Skip to content

Instantly share code, notes, and snippets.

@walf443
Created May 25, 2010 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walf443/413313 to your computer and use it in GitHub Desktop.
Save walf443/413313 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use DBIx::Skinny::SQL;
use Term::ReadLine;
my $rs;
my $PROMPT = ">>> ";
my $term = Term::ReadLine->new('skinny-repl');
my $OUT = $term->OUT || \*STDOUT;
while ( defined( my $line = $term->readline($PROMPT) ) ) {
$rs ||= DBIx::Skinny::SQL->new;
local $@;
my $result = eval $line;
warn $@ if $@;
if ( $result && $rs ) {
printf $OUT "SQL:\n\n%s\nBinds: %s", $rs->as_sql, join(', ', @{ $rs->bind });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment