Re: help creating sqlalchemy/sqlsoup code for sql query

Mary Jane Boholst <[email protected]> Fri, 06 Oct 2006 16:22:33 +0100
Newsgroups gmane.comp.python.spyce.general
Message-ID <[email protected]>
Thank you very much for this very helpful piece of code.
I have another question. (Last one for the week, promise!) I am trying 
to create a button on a page which inserts values from a form into a 
database. I have defined my handler and created the button but the data 
does not seem to be committed to the database. I do not get any error 
messages but checking the database for the data shows that it has not 
been inserted.
The code for my handler is:
[[!
    def insertentry(self, 
api,day,course,timeslottype,start,end,title,tutor):
          
api.db.timetable.insert(day=day,course=course,timeslottype=timeslottype,starttime=start,endtime=end,title=title,givenbby=tutor)
api.db.flush()
]]

The code for the button is:
<f:submit handler=self.insertentry value="Insert entry" />
 From reading around it seems that this should work. Is there something 
I am missing?
Thanks in advance for all help.
MJ
Jonathan Ellis wrote:
> from sqlalchemy import or_
> where = or_(db.timetable.c.course=='LAA', db.timetable.c.course=='COM')
> db.timetable.select(where, order_by=[db.timetable.c.day,
> db.timetable.c.starttime])
>
> On Wed, 4 Oct 2006 11:50:07 +0100, "Mary Jane Boholst"
> <[email protected]> said:
>   
>> Hi again,
>> Another question which should be fairly simple to answer. I am trying to
>> carry 
>> out a fairly word query within my spyce code and am not sure how to do
>> it. 
>> The sql that I want to translate to sqlalchemy is select * from timetable 
>> where course='LAA' or course='COM' order by day, starttime.
>> I have tried several times to do this but I get errors trying to do both
>> the 
>> order by and the where clauses. 
>> Any help will be gratefully received. 
>> Thank you all for your help and suggestions. The login token problem is
>> now 
>> fixed and I have at the moment decided to use the example on the spyce
>> pages 
>> to help with the displaying of different pages for different users.
>> Thanks again,
>> MJ
>>
>> -------------------------------------------------------------------------
>> Take Surveys. Earn Cash. Influence the Future of IT
>> Join SourceForge.net's Techsay panel and you'll get the chance to share
>> your
>> opinions on IT & business topics through brief surveys -- and earn cash
>> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>> _______________________________________________
>> Spyce-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/spyce-users
>>     

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV