推荐学习书目
› 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 · 28932 views
    This topic created in 3947 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
    akafeng
    Feb 9, 2016
    1
    老蔡过年还不忘吸取知识啊
    paicha
    paicha
    Feb 9, 2016❤️1
    2
    修改对象之后,再次 commit
    caixiexin
    caixiexin
    OP
    Feb 9, 2016
    3
    @chinafeng 别打岔- -||
    caixiexin
    caixiexin
    OP
    Feb 9, 2016
    4
    @paicha 直接把 query 出来的对象修改完,然后 db.session.commit()吗?试了下貌似不起作用呢。。
    caixiexin
    caixiexin
    OP
    Feb 9, 2016
    7
    @paicha thanks~
    wellsc
    wellsc
    Feb 9, 2016 via iPhone
    8
    同样也可以使用 Sqlalchemy 的 update 方法。
    honmaple
    honmaple
    Feb 10, 2016 via Android
    9
    一般都是先 query,再 commit ,没有什么问题啊
    honmaple
    honmaple
    Feb 10, 2016 via Android❤️2
    10
    user = User.query.filter_by(id=post_id).first()
    user.name = xxx
    db.session.commit()
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   965 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 22:08 · PVG 06:08 · LAX 14:08 · JFK 17:08
    ♥ Do have faith in what you're doing.