CompileError:未使用的列名称

时间:2016-06-15 21:52:11

标签: python sqlalchemy

我有一个条件,负责根据模型和操作的更改来更新或删除模型。

if change.operation == 'UPDATE':
    db.query(model).filter_by(id=change.old_record_id).update(change.new)
elif change.operation == 'DELETE':
    db.query(model).filter_by(id=change.old_record_id).delete()

db.commit()

当我的代码到达这一点时,它给出: sqlalchemy.exc:CompileError: Unconsumed column names: subscribers

我在这个函数中宣布我的引擎:

def make_session(connection_string):
    engine = create_engine(connection_string, echo=False, convert_unicode=True,
                           pool_size=20, max_overflow=20)
    Session = scoped_session(sessionmaker(bind=engine))
    return Session, engine

完全追溯

错误指向我的示例的第2行,其中更新发生

File ".../site-packages/sqlalchemy/orm/query.py", line 2851, in update
File ".../site-packages/sqlalchemy/orm/persistence.py", line 897, in exec_
File ".../site-packages/sqlalchemy/orm/persistence.py", line 995, in _do_exec
File ".../site-packages/sqlalchemy/orm/session.py", line 1021, in execute
File ".../site-packages/sqlalchemy/engine/base.py", line 841, in execute
File ".../site-packages/sqlalchemy/sql/elements.py", line 322, in _execute_on_connection
File ".../site-packages/sqlalchemy/engine/base.py", line 931, in _execute_clauseelement
File "<string>", line 1, in <lambda>
File ".../site-packages/sqlalchemy/sql/elements.py", line 493, in compile
File ".../site-packages/sqlalchemy/sql/elements.py", line 499, in _compiler
File ".../site-packages/sqlalchemy/sql/compiler.py", line 395, in __init__
File ".../site-packages/sqlalchemy/sql/compiler.py", line 199, in __init__
File ".../site-packages/sqlalchemy/sql/compiler.py", line 222, in process
File ".../site-packages/sqlalchemy/sql/visitors.py", line 80, in _compiler_dispatch
File ".../site-packages/sqlalchemy/sql/compiler.py", line 1814, in visit_update
File ".../site-packages/sqlalchemy/sql/compiler.py", line 2225, in _get_colparams

0 个答案:

没有答案