[Zope] MySQL Select Statements

Michael Blewett michael.blewett@sci.monash.edu.au
Fri, 30 Jun 2000 14:44:55 +1000


Hi Ron,
If I don't specify my Selects using "AS", I then get the following error 
message:

Error Type: KeyError
Error Value: SubjectName

Traceback (innermost last):
   File /usr/local/Zope-2.1.6-linux2-x86/lib/python/ZPublisher/Publish.py, 
line 214, in publish_module
   File /usr/local/Zope-2.1.6-linux2-x86/lib/python/ZPublisher/Publish.py, 
line 179, in publish
   File /usr/local/Zope-2.1.6-linux2-x86/lib/python/Zope/__init__.py, line 
202, in zpublisher_exception_hook
     (Object: ElementWithAttributes)
   File /usr/local/Zope-2.1.6-linux2-x86/lib/python/ZPublisher/Publish.py, 
line 165, in publish
   File /usr/local/Zope-2.1.6-linux2-x86/lib/python/ZPublisher/mapply.py, 
line 160, in mapply
     (Object: dtTestList)
   File /usr/local/Zope-2.1.6-linux2-x86/lib/python/ZPublisher/Publish.py, 
line 102, in call_object
     (Object: dtTestList)
   File /usr/local/Zope-2.1.6-linux2-x86/lib/python/OFS/DTMLDocument.py, 
line 166, in __call__
     (Object: dtTestList)
   File 
/usr/local/Zope-2.1.6-linux2-x86/lib/python/DocumentTemplate/DT_String.py, 
line 502, in __call__
     (Object: dtTestList)
   File 
/usr/local/Zope-2.1.6-linux2-x86/lib/python/DocumentTemplate/DT_In.py, line 
691, in renderwob
     (Object: sqlRetrieveTestList)
KeyError: (see above)


(Where Subjectname was the first field referenced in the DTML document).
Whereas, If I put the SQL as
Select Subjectname AS Subjectname,  etc, then it all works fine.

It's funny that you say 0.2.2 is broken. Apart from this one glitch, it 
works fine for me (although from memory I think we had to do a little bit 
of fiddling at install time to get it to work).


  - Michael


At 00:12 30/06/2000 -0400, Ron Bickers wrote:
>Why do you say you "must" use the AS statement?  Do you get an error
>otherwise?
>
>MySQLdb 0.2.2 is broken when used with ZMySQLDA.  But 0.2.1 works okay for
>me.  Andy Dustman (author of the MySQLdb) said he will fix it and hinted
>that one should use the ZMySQLDA that is on Zope.org (v1.2.0 now I believe).
>Since that one now uses his MySQLdb, he will likely kill off his own DA.
>
>_______________________
>
>Ron Bickers
>Logic Etc, Inc.
>rbickers@logicetc.com
>
>
> > -----Original Message-----
> > From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
> > Michael Blewett
> > Sent: Thursday, June 29, 2000 10:53 PM
> > To: zope@zope.org
> > Subject: [Zope] MySQL Select Statements
> >
> >
> > Hi Everyone,
> > Just need someone to put me straight here. When I use Select
> > statements in
> > an SQL Method I cannot simply :
> >
> > Select Column1, Column2 etc
> > from TableA.
> >
> > Instead I must use the AS statement ie
> >
> > Select Column1 AS Column1, Column2 AS Column2
> > from TableA.
> >
> > Is this just an oddity with the MySQLDA/Db adapters or am I overlooking
> > something blatantly obvious here? All the examples on zope.org don't have
> > the extra "AS Column1" additions on them and I was wondering if this is a
> > Zope/mySQL-unique thing.
> >
> > I'm using Zope (2.1.6) with MySQL (3.22.32) with Zope MySQL Database
> > Adapter (ZMySQLDA) 2.0.0a1 and
> > MySQLdb module release: 0.2.2 .
> >
> > Could someone please let me know as I don't want to have to type
> > the extra
> > bits on all my SQL statements from here on in if I don't need to
> > (I am the
> > world's worst and laziest typist). If it is the case that it's a
> > necessary
> > evil, then I want to put a HowTo or Tip up on zope.org because it
> > took me a
> > while to figure out what I was doing wrong, and if I can save
> > someone else
> > that same wasted time then I would like to. However I wanted to get my
> > facts straight (via all you experts) first.
> >
> > Thanks for any help...
> >
> >   - Michael
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > Michael Blewett
> > Computer Support Mgr - Biological Sciences
> > Monash University (Clayton Campus)
> > Victoria Australia 3168
> >
> > " Can I trade this job for what's behind door #2? "
> >
> >
> > _______________________________________________
> > 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 )
> >
> >

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Michael Blewett
Computer Support Mgr - Biological Sciences
Monash University (Clayton Campus)
Victoria Australia 3168

" Can I trade this job for what's behind door #2? "