Bienvenido a Tecnohackers

Tecnohackers » Programacion » Area de Programacion » Scripting. VBS, Batch, Bash, JavaSript.
 » 

[Perl Tk] Mysql Manager 0.6



Autor Tema: [Perl Tk] Mysql Manager 0.6  (Leído 896 veces)

Desconectado Doddy

  • Veterano
  • ***
  • Mensajes: 249
  • Slow Mind
[Perl Tk] Mysql Manager 0.6
« en: Abril 14, 2012, 07:47:46 pm »
Nueva version Tk de un Mysql manager que hice hace tiempo.

Código: You are not allowed to view links. Register or Login
#!usr/bin/perl
#Mysql Manager 0.6
#Version Tk
#Coded By Doddy H
#Modules
#ppm install http://www.bribes.org/perl/ppm/Scalar-List-Utils.ppd
#ppm install http://www.bribes.org/perl/ppm/Storable.ppd
#ppm install http://www.bribes.org/perl/ppm/DBI.ppd
#ppm install http://theoryx5.uwinnipeg.ca/ppms/DBD-mysql.ppd

use Tk;
use Tk::ROText;
use Tk::PNG;
use DBI;

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

my $color_fondo = "black";
my $color_texto = "orange";

my $nave =
  MainWindow->new( -background => $color_fondo, -foreground => $color_texto );

$nave->title("Mysql Manager 0.6 || Coded By Doddy H");
$nave->geometry("210x160+20+20");
$nave->resizable( 0, 0 );

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

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

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

$nave->Button(
    -text             => "Connect",
    -width            => 13,
    -command          => \&now,
    -background       => $color_fondo,
    -foreground       => $color_texto,
    -activebackground => "orange"
)->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(
            -background => $color_fondo,
            -foreground => $color_texto
        );
        $man->title("Mysql Manager 0.6 || Coded By Doddy H");
        $man->geometry("650x320+20+20");
        $man->resizable( 0, 0 );

        $man->Label(
            -text       => "Query : ",
            -font       => "Impact1",
            -background => $color_fondo,
            -foreground => $color_texto
        )->place( -x => 73, -y => 20 );
        my $ac = $man->Entry(
            -width      => 60,
            -background => $color_fondo,
            -foreground => $color_texto
        )->place( -x => 135, -y => 23 );
        $man->Button(
            -width            => 8,
            -text             => "Execute",
            -command          => \&tes,
            -background       => $color_fondo,
            -foreground       => $color_texto,
            -activebackground => "orange"
        )->place( -x => 510, -y => 23 );
        my $out = $man->Scrolled(
            "ROText",
            -width      => 74,
            -height     => 15,
            -background => $color_fondo,
            -foreground => $color_texto
        )->place( -x => 60, -y => 73 );

        $man->bind( "<Key-Return>" => sub { &tes } );

        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 {
        $man->Dialog(
            -title            => "Error",
            -buttons          => ["OK"],
            -text             => "Error",
            -background       => $color_fondo,
            -foreground       => $color_texto,
            -activebackground => $color_texto
        )->Show();
    }
}

# ¿ The End ?

You are not allowed to view links. Register or Login

Tags:
Tags:

 


SMF 2.0.19 | SMF © 2016, Simple Machines
Paginas Afiliadas
Twitter - FaceBook - Daraxblog
Designed by Smf Personal