skywatcher
V2EX  ›  Flask

flask-sqlalchemy 中提示找不到 event?

  •  
  •   skywatcher · Jan 19, 2016 · 3658 views
    This topic created in 3775 days ago, the information mentioned may be changed or developed.
    // models.py
    db.event.listen(User.declare, 'set', User.declare_cache)
    
    File "E:\Program\python\1\myapp\models.py", line 156, in <module>
        db.event.listen(User.declare, 'set', User.declare_cache)
    AttributeError: 'SQLAlchemy' object has no attribute 'event'
    
    florije
        1
    florije  
       Jan 19, 2016
    一般这么使用:
    from sqlalchemy import event
    event.listen(something)
    skywatcher
        2
    skywatcher  
    OP
       Jan 19, 2016
    @florije 上面那么用是用的 Flask-SQLAlchemy ;但是你说的这招也用过了,报的错是: TypeError: 'InstrumentedAttribute' object is not callable
    skywatcher
        3
    skywatcher  
    OP
       Jan 19, 2016
    @florije 对的,我之前忽略调用函数
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3493 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 04:47 · PVG 12:47 · LAX 21:47 · JFK 00:47
    ♥ Do have faith in what you're doing.