Re: Perl to Python using MqSQLdb

2008-08-13 Thread Fredrik Lundh
Mike P wrote: That is a nice piece of code, I cracked the idea of the shift; problem, my final problem is still how to convert my @row = $sth->fetchrow_array; $$StartDate = $row[0]; $$EndDate = $row[1]; $sth->finish() into python code as i'm not sure what $$ means according to a

Re: Perl to Python using MqSQLdb

2008-08-13 Thread Fredrik Lundh
Jeroen Ruigrok van der Werven wrote: cursor=db.cursor() cursor.execute(sql) while (1): row = cursor.fetchone() if row == None: break combined = ', '.join(row) Why not something like: for row in cursor.fetchall(): combined = ', '.join(row) which ca

Re: Perl to Python using MqSQLdb

2008-08-13 Thread Mike P
That is a nice piece of code, I cracked the idea of the shift; problem, my final problem is still how to convert my @row = $sth->fetchrow_array; $$StartDate = $row[0]; $$EndDate = $row[1]; $sth->finish() into python code as i'm not sure what $$ means Any help on this final part woul

Re: Perl to Python using MqSQLdb

2008-08-13 Thread Jeroen Ruigrok van der Werven
-On [20080812 15:16], Daniel Mahoney ([EMAIL PROTECTED]) wrote: >cursor=db.cursor() >cursor.execute(sql) >while (1): > row = cursor.fetchone() > if row == None: > break > combined = ', '.join(row) Why not something like: for row in cursor.fetchall(): combined =

Re: Perl to Python using MqSQLdb

2008-08-13 Thread Mike P
Thanks for that Daniel, I've been able to apply the logic to the rest of the script i'm converting. There are only two bits that i don't understand in the Perl script that i need to convert, my $sql = shift; and my @row = $sth->fetchrow_array; $$StartDate = $row[0]; $$EndDate = $row[1]

Re: Perl to Python using MqSQLdb

2008-08-12 Thread Daniel Mahoney
On Tue, 12 Aug 2008 05:51:19 -0700, Mike P wrote: > 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

Perl to Python using MqSQLdb

2008-08-12 Thread Mike P
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 "C