如何在sqlalchemy中使用modulo?

时间:2018-01-03 06:48:18

标签: python sqlalchemy

我有这个原始的SQL语句,我想用于Core和ORM:

SELECT * FROM `buffet` WHERE `roomId` = '864495034004835' AND `recordMasa` > '1514600000' AND `recordMasa` < '1514900000' AND `recordMasa` mod 10 = 0 LIMIT 0,10000000000;

请告诉我如何添加到下面的现有代码中以包含模数函数:

select_statement = select([Buffet]).where(and_(
        Buffet.recordMasa > arguments['startDate'],
        Buffet.recordMasa < arguments['endDate'],
        Buffet.roomId == arguments['ident']
    ))
rooms = conn.execute(select_statement).fetchall()

1 个答案:

答案 0 :(得分:2)

来自python的the modulo operato r怎么办?

select_statement = select([Buffet]).where(and_(
        Buffet.recordMasa > arguments['startDate'],
        Buffet.recordMasa < arguments['endDate'],
        Buffet.roomId == arguments['ident'],
        Buffet.recordMasa % 10 == 0,
    ))