Perl to Python using MqSQLdb

Mike P michael.pearmain at tangozebra.com
Tue Aug 12 14:51:19 CEST 2008


Hi All,

I've been given a Perl script that i'm trying to convert into python.
The aim of the script links to MqSQL database, but i'm stuck on one
part

   my $sth = $dbh->prepare($sql)||
       die "Could not prepare SQL statement ... maybe invalid?:$!\n$sql
\n";
   $sth->execute()||
       die "Could not execute SQL statement ... maybe invalid?:$!\n$sql
\n";

   while (my @row= $sth->fetchrow_array())  {
      my $combined = join(",", @row);
      print "$combined\n";
   }

I don't know much MySQL or Perl..

Can anyone help to convert this for me?

Mike



More information about the Python-list mailing list