V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
guotie
V2EX  ›  问与答

sqlalchemy的orm怎么使用or关系?

  •  
  •   guotie · Jun 9, 2012 · 4023 views
    This topic created in 5075 days ago, the information mentioned may be changed or developed.
    如题。

    and关系可以用query.filter().filter(),or关系怎么用?文档上没找到。

    谢谢!
    2 replies    1970-01-01 08:00:00 +08:00
    SErHo
        1
    SErHo  
       Jun 9, 2012   ❤️ 1
    guotie
        2
    guotie  
    OP
       Jun 9, 2012
    from sqlalchemy import or_
    filter(or_(User.name == 'ed', User.name == 'wendy'))
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2348 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 10:53 · PVG 18:53 · LAX 03:53 · JFK 06:53
    ♥ Do have faith in what you're doing.