我正在编写一个web2py查询来对数据库运行,但它不会显示结果,因为我收到一条错误,说明设置:没有选择表...
我想知道是否有人可以帮我解决这个问题?
我要运行查询的表是:
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'))
我的查询是:
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)
有人可以帮我纠正这个问题吗?
答案 0 :(得分:0)
查询必须使用==
构建,而不是is
:
db.Flight.DepartureLocation == request.vars.DepartureLocation