AttributeError while querying: Neither 'InstrumentedAttribute' object nor 'Comparator' has an attribute

前端 未结 4 1361
旧巷少年郎
旧巷少年郎 2021-01-31 14:33

The following code:

Base = declarative_base()
engine = create_engine(r\"sqlite:///\" + r\"d:\\foo.db\",
                       listeners=[ForeignKeysListener()])         


        
4条回答
  •  无人共我
    2021-01-31 14:59

    I was getting the same error Neither 'InstrumentedAttribute' object nor 'Comparator' has an attribute, but in my case, the problem was my model contained a Column named query, which was overwriting the internal property model.query.

    I decided to rename that Column to query_text and that removed the error. Alternatively, passing the name= argument to the Column method would have worked: query = db.Column(db.TEXT, name='query_text').

提交回复
热议问题