Un simple mysql manager en version grafica.

El codigo :
#!usr/bin/perl
#Mysql Manager Tk (C) Doddy Hackman 2011
#ppm install http://www.bribes.org/perl/ppm/DBI.ppd

use Tk;
use Tk::ROText;
use DBI;
use Win32;

if ($^O eq 'MSWin32') {
use Win32::Console; 
Win32::Console::Free();
}

my $nave = MainWindow->new();

$nave->title("Mysql Manager");
$nave->geometry("200x170+20+20");
$nave->resizable(0,0);

$nave->Label(-text=>"Host : ",-font=>"Impact1")->place(-x=>10,-y=>10);
my $host = $nave->Entry(-width=>20,-text=>"localhost")->place(-x=>60,-y=>13);

$nave->Label(-text=>"User : ",-font=>"Impact1")->place(-x=>10,-y=>40);
my $user = $nave->Entry(-width=>20,-text=>"root")->place(-x=>60,-y=>43);

$nave->Label(-text=>"Pass : ",-font=>"Impact1")->place(-x=>10,-y=>70);
my $pass = $nave->Entry(-width=>20)->place(-x=>60,-y=>73);

$nave->Button(-text=>"Connect",-width=>13,-command=>\&now)->place(-x=>60,-y=>120);

MainLoop;

sub now {

my $host = $host->get;
my $user = $user->get;
my $pass = $pass->get;

$info = "dbi:mysql::".$host.":3306";

if (my $enter = DBI->connect($info,$user,$pass,{PrintError=>0})) {
$nave->destroy;
my $man = MainWindow->new();
$man->title("Mysql Manager (C) Doddy Hackman 2011");
$man->geometry("350x290+20+20");
$man->resizable(0,0);
$man->Label(-text=>"Query : ",-font=>"Impact1")->place(-x=>10,-y=>10);
my $ac = $man->Entry(-width=>30)->place(-x=>70,-y=>15);
$man->Button(-width=>8,-text=>"Execute",-command=>\&tes)->place(-x=>267,-y=>13);
my $out = $man->ROText(-width=>44,-height=>15)->place(-x=>13,-y=>55);


sub tes {
my $ac = $ac->get;
$re = $enter->prepare($ac);
$re->execute();
my $total = $re->rows();

my @columnas = @{$re->{NAME}};

if ($total eq "-1") {
$out->insert("end","\n[-] Query Error\n");
next;
} else {
$out->insert("end","\n[+] Result of the query\n");
if ($total eq 0) {
$out->insert("end","\n[+] Not rows returned\n\n");
} else {
$out->insert("end","\n[+] Rows returned : ".$total."\n\n");
for(@columnas) {
$out->insert("end",$_."\t");
}
$out->insert("end","\n\n");
while (@row = $re->fetchrow_array) {
for(@row) {
$out->insert("end",$_."\t");
}
$out->insert("end","\n");
}}}}
} else {
Win32::MsgBox("Error in the connection",0,"Mysql Manager");
}}

# ¿ The End ?
Algunas imagenes

Imagen


Imagen


Eso es todo
Responder

Volver a “Otros lenguajes de Scripting”