Skip to content

Instantly share code, notes, and snippets.

@hectorgool
Created February 27, 2017 13:25
Show Gist options
  • Select an option

  • Save hectorgool/009b036906a448ec78c66e81dcb18465 to your computer and use it in GitHub Desktop.

Select an option

Save hectorgool/009b036906a448ec78c66e81dcb18465 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
#aptitude install libdbd-pg-perl libdbi-perl -y
use DBI;
system("clear");
my $dbh = DBI->connect("DBI:Pg:dbname=hem;host=localhost", "hem", "asdfasdf", {'RaiseError' => 1});
$sth = $dbh->prepare("SELECT * FROM products ORDER BY name");
$sth->execute();
while ( $row = $sth->fetchrow_hashref ) {
print "$row->{name}\t$row->{description}\n";
}
$dbh->disconnect( );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment