I am writing a web2py query to run against the database but it won't display the results as i get an error stating Set: No tables selected...
I was wondering if some one can help me out with this?
The table I was to run the query against is:
db.define_table('Flight',
Field('FlightNum', type = 'string', length = 10, notnull = True),
Field('PlaneID', type = 'string', length = 10, notnull = True),
Field('DepartureLocation', type = 'string', length = 20, notnull = True),
Field('ArrivalLocation', type = 'string', length = 20, notnull = True),
Field('DepartureDate', type='date'),
Field('ArrivalDate', type='date'),
Field('DepartureTime', type = 'time'),
Field('ArrivalTime', type = 'time'))
My query is:
def displayFlights():
tuples=db((db.Flight.DepartureLocation is request.vars.DepartureLocation)&
(db.Flight.ArrivalLocation is request.vars.ArrivalLocation)&
(db.Flight.DepartureDate is request.vars.DepartureDate)&
(db.Flight.ArrivalDate is request.vars.DepartureDate)).select()
return dict(tuples=tuples)
Can some one please help me correct this query?
Queries must be constructed with ==
, not is
:
db.Flight.DepartureLocation == request.vars.DepartureLocation