[Zope] PYTHON script

Norman Khine khine@btinternet.com
Tue, 12 Jun 2001 00:12:38 +0100


Thanks a lot guys, appreciated ;^)

-----Original Message-----
From: Peter Kropf [mailto:peter@verecomm.com]
Sent: 11 June 2001 23:31
To: 'Norman Khine'
Subject: RE: [Zope] PYTHON script


Quotes within quotes - Try:

b.execute("SELECT location, SUM(IF(gender='M',1,0)) AS M,
SUM(IF(gender='F',1,0)) AS F FROM locations INNER JOIN employees USING
(loc_code) GROUP BY location")

- Peter


> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
> Norman Khine
> Sent: Monday, June 11, 2001 3:20 PM
> To: Zope
> Subject: [Zope] PYTHON script
>
>
> Hello I have a MySQL database and I can run the following
> script using the
> command prompt
>
> SELECT location, SUM(IF(gender='M',1,0)) AS M,
> SUM(IF(gender='F',1,0)) AS F
> FROM locations INNER JOIN employees USING (loc_code) GROUP BY
> location;
>
> this also works within Zope
>
> but when I try to run this from the python prompt I get an
>
> File "<stdin>", line 1
>     b.execute('SELECT location, SUM(IF(gender='M',1,0)) AS M,
> SUM(IF(gender='F',1,0)) AS F FROM locations INNER JOIN employees USING
> (loc_code) GROUP BY location')
>                                                ^
> SyntaxError: invalid syntax
>
> this is what I did
>
> >>import MySQLdb
> >>db = MySQLdb.connect(db='mydb',user='myuser',passwd='mypasswd')
> >>b = db.cursor()
> >>b.execute('myquery')
>
> error
>
> any ideas
>
> thanks
>
> norman
>
> ps perhaps this post is more suited to the python mail list,
> please forgive
> as I am only a member of the zope community.;^)
>
> zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
> zz/********/z/****\zzz|****\*\zz|*******|z
> z/^^^^^^^^/z/******\zz|*^^^^|*|z|*|^^^^^|z norman khine
> zzzzzz/**/z|**/^^\**|z|*|zzz|*|z|*|zzzzzzz mailto:norman@khine.net
> zzzzz/**/zz|*|zzzz|*|z|****/*/zz|*****|zzz purley
> z/******/zz|*|zzzz|*|z|*|^^zzzzz|*|^^^|zzz UK
> zzZ/**/zzzz|**\^^/**|z|*|zzzzzzz|*|zzzzzzz
> zz/******/zz\******/zz|*|zzzzzzz|*|*****|z
> z/^^^^^^/zzzz\^^^^/zzz|^|zzzzzzz|^^^^^^^|z
> zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
>
>
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )