in reply to Perl/Tk freezes while waiting the data to arrive on mysql server

I see what you're trying to do, and you're pretty close, but you're missing a couple important points. You want to have an extended number of rows from the query displayed in a ROText widget (which, by default, will be scrollable using arrow keys or the mouse scroll wheel). But, as pointed out above, your query returns only one row, and doesn't match up with your attempted use of bind_columns.

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):

#!/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;
(I tested something pretty similar to that on a database of my own, so it ought to work for you.)
  • Comment on Re: Perl/Tk freezes while waiting the data to arrive on mysql server
  • Download Code