I am using SQLAlchemy ORM with MariaDB (mariadbconnector). The database updates with the add_conversation function but when trying to update a value it does nothing and there is no error. Instead of filter_by() I tried get() but then I received this error:
AttributeError: 'NoneType' object has no attribute 'answer_sent'
The row and column exist so I'm not sure where I am going wrong.
def add_conversation(conversation_id, chat_start, chat_end, answer_sent, answer_accepted):
new_conversation = Conversation(conversation_id=conversation_id, chat_start=chat_start, chat_end=chat_end,
answer_sent=answer_sent, answer_accepted=answer_accepted)
session.add(new_conversation)
session.commit()
add_conversation(19156050, 1645552829, 1645559831, False, False)
def set_answer_sent(conversation_id):
convo = session.query(Conversation).filter_by(conversation_id=conversation_id)
convo.answer_sent = True
session.commit()
session.flush()
set_answer_sent(19156050)