推荐学习书目
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
caixiexin
V2EX  ›  Python

flask-SQLAlchemy 的 update 操作是怎么用的呢?

  •  
  •   caixiexin · Feb 9, 2016 · 28713 views
    This topic created in 3820 days ago, the information mentioned may be changed or developed.
    求教,为啥我在官网的教程里只发现 insert query 和 delete - -
    http://flask-sqlalchemy.pocoo.org/2.1/queries/
    10 replies    2016-02-10 01:15:57 +08:00
    akafeng
        1
    akafeng  
       Feb 9, 2016
    老蔡过年还不忘吸取知识啊
    paicha
        2
    paicha  
    PRO
       Feb 9, 2016   ❤️ 1
    修改对象之后,再次 commit
    caixiexin
        3
    caixiexin  
    OP
       Feb 9, 2016
    @chinafeng 别打岔- -||
    caixiexin
        4
    caixiexin  
    OP
       Feb 9, 2016
    @paicha 直接把 query 出来的对象修改完,然后 db.session.commit()吗?试了下貌似不起作用呢。。
    caixiexin
        7
    caixiexin  
    OP
       Feb 9, 2016
    @paicha thanks~
    wellsc
        8
    wellsc  
       Feb 9, 2016 via iPhone
    同样也可以使用 Sqlalchemy 的 update 方法。
    honmaple
        9
    honmaple  
       Feb 10, 2016 via Android
    一般都是先 query,再 commit ,没有什么问题啊
    honmaple
        10
    honmaple  
       Feb 10, 2016 via Android   ❤️ 2
    user = User.query.filter_by(id=post_id).first()
    user.name = xxx
    db.session.commit()
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   822 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 21:34 · PVG 05:34 · LAX 14:34 · JFK 17:34
    ♥ Do have faith in what you're doing.