The following code:
Base = declarative_base()
engine = create_engine(r\"sqlite:///\" + r\"d:\\foo.db\",
listeners=[ForeignKeysListener()])
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')
.