Бд:
class Questionnaire(Base):
__tablename__ = "questionnaire"
user = Column(String(30), primary_key=True)
username = Column(String(30))
photo = Column(String(100))
about = Column(String(500))
sex = Column(String(500))
city = Column(String(30))
find = Column(String(400))
def __repr__(self):
return f"Questionnaire(" \
f"id={self.id!r}, user={self.user!r}, photo={self.photo!r}, about={self.about!r}, sex={self.sex!r}," \
f" city={self.city!r}, find={self.find!r}"
Функция редактирования:
def edit_questionnaire(user_id, username):
with Session(engine) as session:
stmt = select(Questionnaire).where(Questionnaire.user == user_id)
questionnaire = engine.connect().execute(stmt).fetchone()
if questionnaire:
questionnaire.username = f'@{username}'
session.add(questionnaire)
session.commit()
traceback:
Task exception was never retrieved
future: <Task finished name='Task-39' coro=<Dispatcher._process_polling_updates() done, defined at D:\Да это же мой код\Aiogram\DatingBotPrototype\venv\lib\site-packages\aiogram\dispatcher\dispatcher.py:407> exception=AttributeError("can't set attribute")>
Traceback (most recent call last):
File "D:\Да это же мой код\Aiogram\DatingBotPrototype\venv\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 415, in _process_polling_updates
for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
File "D:\Да это же мой код\Aiogram\DatingBotPrototype\venv\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 235, in process_updates
return await asyncio.gather(*tasks)
File "D:\Да это же мой код\Aiogram\DatingBotPrototype\venv\lib\site-packages\aiogram\dispatcher\handler.py", line 116, in notify
response = await handler_obj.handler(*args, **partial_data)
File "D:\Да это же мой код\Aiogram\DatingBotPrototype\venv\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 256, in process_update
return await self.message_handlers.notify(update.message)
File "D:\Да это же мой код\Aiogram\DatingBotPrototype\venv\lib\site-packages\aiogram\dispatcher\handler.py", line 116, in notify
response = await handler_obj.handler(*args, **partial_data)
File "D:\Да это же мой код\Aiogram\DatingBotPrototype\handlers\user_edit_handler.py", line 91, in get_accept
edit_questionnaire(message.from_user.id, message.from_user.username)
File "D:\Да это же мой код\Aiogram\DatingBotPrototype\database\responces.py", line 27, in edit_questionnaire
questionnaire.username = f'@{username}'
File "D:\Да это же мой код\Aiogram\DatingBotPrototype\venv\lib\site-packages\sqlalchemy\engine\row.py", line 219, in __setattr__
raise AttributeError("can't set attribute")
AttributeError: can't set attribute
Бд создана, соответствующая запись в ней есть и оно её видит, но изменить нельзя.