Perl to Python using MqSQLdb

Mike P michael.pearmain at tangozebra.com
Tue Aug 12 08:51:19 EDT 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