Saving data into db using SqlAlchemy, object is not subscriptable

后端 未结 1 1957
灰色年华
灰色年华 2021-01-20 16:01

I\'m trying to insert some data into a database, unfortunately it fails and does not save, I suspect my data is structured in a bad way. The data gets printed nicely (1 titl

1条回答
  •  被撕碎了的回忆
    2021-01-20 16:31

    You should use:

    if session.query(Presstv).filter_by(link=item.link) == None:
    

    as item is now a object from SQLAlchemy. This probably happened because you are using items['link'] a few lines before that but item is now an instance of that class so you should access its values using .link.

    0 讨论(0)
提交回复
热议问题