[web2py] Re: Query not returning correct data

2013-01-17 Thread Alan Etkin
I'd suggest a couple of changes: - Change CamelCase (used in Python class definitions) with the_more_appropiate_convention for object attributes. - Those foreign keys you have declared as ThingId should be renamed as thing_id (for a more web2py like naming style) - Reference keys (links to other

[web2py] Re: Query not returning correct data

2013-01-17 Thread Mihir Lade
Hi Alan, Sorry for the late reply.. Table Definition: ##Customer table. db.define_table('Customer', Field('CustID', type = 'string', length = 10, notnull = True, unique = True), Field('Surname', type = 'string', length = 15, notnull = True), Field('FirstName', type = 'string', len

[web2py] Re: Query not returning correct data

2013-01-17 Thread Alan Etkin
> > I've tried that however when I hit search flight button it returns an > empty page with no data from the database... > Please post your model also (the table definitions). And consider using SQLFORM , as Anthony suggested, or CRU

[web2py] Re: Query not returning correct data

2013-01-16 Thread Mihir Lade
Hello Sir, I've tried that however when I hit search flight button it returns an empty page with no data from the database... --

[web2py] Re: Query not returning correct data

2013-01-16 Thread Massimo Di Pierro
This query1 = SQLTABLE(db().select(db.Flight.DepartureDate == request.vars.DepartureDate)) is wrong in many ways. First of all it is not a query (it is an HTML table). Second, you pass a query as argument of select. That does not mean what you think it does. Should be def displayFlights():

[web2py] Re: Query not returning correct data

2013-01-16 Thread Mihir Lade
Hi Anthony, I am currently working with this code: def displayFlights(): query1 = SQLTABLE(db().select(db.Flight.DepartureDate == request.vars.DepartureDate)) query2 = SQLTABLE(db().select(db.Flight.ArrivalLocation == request.vars.ArrivalLocation)) query3 = SQLTABLE(db().select(db

[web2py] Re: Query not returning correct data

2013-01-16 Thread Anthony
On Wednesday, January 16, 2013 9:39:39 AM UTC-5, Mihir Lade wrote: > Hi Anthony, > > I tired as you recommended above with the INPUT statement.. however > another I encounter another ticket: > > if form.accepts(request.vars, session): > AttributeError: 'tuple' object has no attribute 'accepts

[web2py] Re: Query not returning correct data

2013-01-16 Thread Mihir Lade
Hi Anthony, I tired as you recommended above with the INPUT statement.. however another I encounter another ticket: if form.accepts(request.vars, session): AttributeError: 'tuple' object has no attribute 'accepts' --

[web2py] Re: Query not returning correct data

2013-01-16 Thread Anthony
> > I am getting an error with this stating: form=FORM(TABLE(TR("Departure Location: ", INPUT(_type="text", _name="DepartureLocation", IS_IN_SET(states), TR("Arrival Location: ", INPUT(_type="text", _name="ArrivalLocation", IS_IN_SET(states))), TR("", INPUT(_type="submit", _value="Submit

[web2py] Re: Query not returning correct data

2013-01-16 Thread Mihir Lade
Hi Anthony, Thanks for the reply.. this all seems a bit out of my league.. --

[web2py] Re: Query not returning correct data

2013-01-16 Thread Anthony
Looks like you might have some unbalanced parentheses here and there (and a missing comma in the returned dict). Also, in Python, instead of: if len(something) == 0: your can generally just do: if not something: Empty and zero length objects (as well as None) evaluate to False. Finally, note

[web2py] Re: Query not returning correct data

2013-01-16 Thread Mihir Lade
Hi Anthony, As mentioned on Stack Overflow: I am currently working with the FORM because this is very frustrating that the query isn't working properly or I can't seen to figure out how to get it working properly.. with the form this is the code that I am using.. this is just a prototype to

[web2py] Re: Query not returning correct data

2013-01-16 Thread Anthony
Answered on Stack Overflow: http://stackoverflow.com/a/14358733/440323 First, Alan is correct -- you cannot use "is" to create queries (that will just create booleans rather than queries). You must use ==, !=, <, >, <=, >=, &, |. These operators have been overloaded so that when used with DAL F

[web2py] Re: Query not returning correct data

2013-01-16 Thread Mihir Lade
Hi Alan, I tried changing to == however now it won't return any data at all... Another way i was trying was.. def displayFlights(): tuples=db((db.Flight.DepartureLocation is request.vars.DepartureLocation)& (db.Flight.ArrivalLocation is request.vars.ArrivalLocation)& (db.Fli

[web2py] Re: Query not returning correct data

2013-01-16 Thread Alan Etkin
> I am currently working on a query which is meant to search the database and return the flights that the users wants.. I've never seen a query built with the is operator before, chances are that it's not supported. I'd try instead: query1 = db.Flight.DepartureDate==request.vars.DepartureDate q