推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
yikoda
V2EX  ›  Python

求一句 sql 转化为 sqlalchemy 怎么写

  •  
  •   yikoda · Jul 15, 2016 · 3353 views
    This topic created in 3591 days ago, the information mentioned may be changed or developed.

    select * from user where (in, use_name) in ((10, ''zhangsan), (20, ''lisi))

    7 replies    2016-07-16 08:12:14 +08:00
    yikoda
        1
    yikoda  
    OP
       Jul 15, 2016
    突然卡到这~ 好 tama 难、
    JhZ7z587cYROBgVQ
        2
    JhZ7z587cYROBgVQ  
       Jul 15, 2016
    ```query(user).filter((user.in, user.use_name) in ((10, 'zhangsan'), (20, 'lisi'))).all()``` 这样子?,不是很看得懂那两个字段哎
    eriale
        3
    eriale  
       Jul 15, 2016
    session.query(user).filter(text("(in, user_name) in ((10, 'zhangsan'), (20, lisi'))")).all()
    yikoda
        4
    yikoda  
    OP
       Jul 15, 2016
    @eriale 貌似不行~ orm 和 sql 混用不起来~
    mxi1
        5
    mxi1  
       Jul 15, 2016
    sqlalchemy 的一般用法,不是先定义一个 User 的 class ,然后通过 db_session 去 query 、 filter 吗?😅
    valuedlute
        6
    valuedlute  
       Jul 15, 2016
    嫌麻烦的话 session.execute(sql)
    aristotll
        7
    aristotll  
       Jul 16, 2016
    r#6 @mickeyandkaka 高 简单粗暴...
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1044 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 18:40 · PVG 02:40 · LAX 11:40 · JFK 14:40
    ♥ Do have faith in what you're doing.