@start_router.message(Form.name)
async def add_name(message: types.Message):
user_name = message.text.strip()
async with aiosqlite.connect('base.db') as db:
await db.execute('INSERT OR IGNORE INTO user (name) VALUES("%s")' % (user_name))
await db.commit()
await message.answer("Готово")
@dp.message_handler(state=Form.name)
async def add_name(message: types.Message):
user_name = message.text.strip()
try:
async with aiosqlite.connect('base.db') as db:
await db.execute('INSERT OR IGNORE INTO user (name) VALUES (?)', (user_name,))
await db.commit()
await message.answer("Готово")
except Exception as e:
await message.answer(f"Произошла ошибка {e}")