in reply to Perl/Tk freezes while waiting the data to arrive on mysql server
Try it like this (I'm only changing the bare minimum to do what I think you really want, but I'm not able to test it):
(I tested something pretty similar to that on a database of my own, so it ought to work for you.)#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::ROText; use DBI; ## use DBD::mysql; # DBI will do this for you when you connect our $type="mysql"; our $database="beezynet_db"; our $host="http://www.xsite.com/"; our $port="3306"; our $tablename="topic"; our $user="username123"; our $pwd="**************"; our $dsn="dbi:$type:$database:$host:$port"; my $query; my $queryhandle; our $connect=DBI->connect($dsn,$user,$pwd)or die &mysql_Err; my $mw=new MainWindow; $mw->geometry('400x400'); my $rotext=$mw->ROText()->pack; # I can only guess at the real column names - please fix them as neede +d: $query="SELECT id, item_name, item_price FROM items ORDER BY id"; my ( $id, $item_name, $item_price ); $queryhandle=$connect->prepare($query); $queryhandle->execute; $queryhandle->bind_columns(undef, \$id, \$item_name, \$item_price); while($queryhandle->fetch()){ # NB: use "end" instead of "1.0" here: $rotext->insert('end', "ID: $id\t Price:: $item_price\tName: \$ite +m_name"); } $queryhandle->finish; # $connect->disconnect; ## display will work, even while connected. MainLoop;
|
|---|