async def user_exists(user_id):
conn = await asyncpg.connect(host=host, user=user, password=password, database=database)
try:
return await conn.fetchrow(f"SELECT 1 FROM users WHERE (user_id=$1) LIMIT 1;", user_id)
finally:
await conn.close()
async def add_name(state):
conn = await asyncpg.connect(host=host, user=user, password=password, database=database)
async with state.proxy() as data:
await conn.execute("""UPDATE users SET name = $1 WHERE name = null;""", tuple(data))
await conn.close()
@dp.message_handler(state=AddName.name)
async def add_name(message: types.Message, state=FSMContext):
async with state.proxy() as data:
data["name"] = message.text
await state.finish()
if await user.user_exists(message.from_user.id) == message.from_user.id:
await user.add_name(state)
await message.answer('Имя было добавлен')
Task exception was never retrieved
future: <Task finished name='Task-18' coro=<Dispatcher._process_polling_updates() done, defined at C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\dispatcher.py:407> exception=AttributeError("'Protocol' object has no attribute '_on_error'")>
Traceback (most recent call last):
File "asyncpg\protocol\protocol.pyx", line 951, in asyncpg.protocol.protocol.BaseProtocol.connection_made
File "asyncpg\protocol\coreproto.pyx", line 859, in asyncpg.protocol.protocol.CoreProtocol._connect
TypeError: Expected unicode, got tuple
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python310\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 "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 235, in process_updates
return await asyncio.gather(*tasks)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\handler.py", line 117, in notify
response = await handler_obj.handler(*args, **partial_data)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 256, in process_update
return await self.message_handlers.notify(update.message)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\aiogram\dispatcher\handler.py", line 117, in notify
response = await handler_obj.handler(*args, **partial_data)
File "C:\Users\User\PycharmProjects\bot_ton\handlers\client.py", line 37, in add_ton
await new_ton.add_wallets(wallet)
File "C:\Users\User\PycharmProjects\bot_ton\data_base\new_ton.py", line 10, in add_wallets
conn = await asyncpg.connect(user=user, password=password, database=database, host=host)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\asyncpg\connection.py", line 2092, in connect
return await connect_utils._connect(
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\asyncpg\connect_utils.py", line 881, in _connect
return await _connect_addr(
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\asyncpg\connect_utils.py", line 773, in _connect_addr
return await __connect_addr(params, timeout, True, *args)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\asyncpg\connect_utils.py", line 825, in __connect_addr
tr, pr = await compat.wait_for(connector, timeout=timeout)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\asyncpg\compat.py", line 56, in wait_for
return await asyncio.wait_for(fut, timeout)
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\tasks.py", line 445, in wait_for
return fut.result()
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\asyncpg\connect_utils.py", line 710, in _create_ssl_connection
pg_proto.connection_made(new_tr)
File "asyncpg\protocol\protocol.pyx", line 956, in asyncpg.protocol.protocol.BaseProtocol.connection_made
AttributeError: 'Protocol' object has no attribute '_on_error'
К сожалению, от ошибки это не избавило