0

我正在编写一个 web2py 查询来针对数据库运行,但它不会显示结果,因为我收到一条错误消息:Set: No tables selected...

我想知道是否有人可以帮助我解决这个问题?

我要运行查询的表是:

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)

有人可以帮我更正这个查询吗?

4

1 回答 1

0

查询必须用 构造==,而不是is

db.Flight.DepartureLocation == request.vars.DepartureLocation
于 2013-01-16T12:42:04.843 回答