@Hy1lite

Как исправить ошибку датабазы в тг боте aiogram PostgreSQL?

при попытке заставить работать бота в тг с датабазой PostgreSQL возникает ошибка
(.venv) kirill@compute-vm-2-2-20-hdd-1730313864382:~/easy_refer_bot$ python aiogram_run.py
2024-11-05 19:23:52,288 - INFO - Database instance created with log level: INFO
2024-11-05 19:23:52,288 - asyncpg_lite - INFO - Database instance created with log level: INFO
2024-11-05 19:23:52,648 - INFO - Connect with PostgreSQL success!
2024-11-05 19:23:52,648 - asyncpg_lite - INFO - Connect with PostgreSQL success!
2024-11-05 19:23:52,705 - INFO - Disconnected from the database.
2024-11-05 19:23:52,705 - asyncpg_lite - INFO - Disconnected from the database.
Traceback (most recent call last):
  File "/home/kirill/easy_refer_bot/aiogram_run.py", line 54, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/kirill/easy_refer_bot/aiogram_run.py", line 48, in main
    await dp.start_polling(bot, allowed_updates=dp.resolve_used_update_types())
  File "/home/kirill/easy_refer_bot/.venv/lib/python3.12/site-packages/aiogram/dispatcher/dispatcher.py", line 526, in start_polling
    await self.emit_startup(bot=bots[-1], **workflow_data)
  File "/home/kirill/easy_refer_bot/.venv/lib/python3.12/site-packages/aiogram/dispatcher/router.py", line 256, in emit_startup
    await self.startup.trigger(*args, **kwargs)
  File "/home/kirill/easy_refer_bot/.venv/lib/python3.12/site-packages/aiogram/dispatcher/event/event.py", line 42, in trigger
    await handler.call(*args, **kwargs)
  File "/home/kirill/easy_refer_bot/.venv/lib/python3.12/site-packages/aiogram/dispatcher/event/handler.py", line 43, in call
    return await wrapped()
           ^^^^^^^^^^^^^^^
  File "/home/kirill/easy_refer_bot/aiogram_run.py", line 19, in start_bot
    count_users = await get_all_users(count=True)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kirill/easy_refer_bot/db_handler/db_funk.py", line 30, in get_all_users
    all_users = await client.select_data(table_name=table_name)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kirill/easy_refer_bot/.venv/lib/python3.12/site-packages/asyncpg_lite/__init__.py", line 197, in select_data
    table = await self.get_table(table_name)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kirill/easy_refer_bot/.venv/lib/python3.12/site-packages/asyncpg_lite/__init__.py", line 181, in get_table
    table = Table(table_name, self.metadata, autoload_with=conn)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 2, in __new__
  File "/home/kirill/easy_refer_bot/.venv/lib/python3.12/site-packages/sqlalchemy/util/deprecations.py", line 281, in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^
  File "/home/kirill/easy_refer_bot/.venv/lib/python3.12/site-packages/sqlalchemy/sql/schema.py", line 427, in __new__
    return cls._new(*args, **kw)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/kirill/easy_refer_bot/.venv/lib/python3.12/site-packages/sqlalchemy/sql/schema.py", line 481, in _new
    with util.safe_reraise():
  File "/home/kirill/easy_refer_bot/.venv/lib/python3.12/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/home/kirill/easy_refer_bot/.venv/lib/python3.12/site-packages/sqlalchemy/sql/schema.py", line 477, in _new
    table.__init__(name, metadata, *args, _no_init=False, **kw)
  File "/home/kirill/easy_refer_bot/.venv/lib/python3.12/site-packages/sqlalchemy/sql/schema.py", line 857, in __init__
    self._autoload(
  File "/home/kirill/easy_refer_bot/.venv/lib/python3.12/site-packages/sqlalchemy/sql/schema.py", line 887, in _autoload
    insp = inspection.inspect(autoload_with)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/kirill/easy_refer_bot/.venv/lib/python3.12/site-packages/sqlalchemy/inspection.py", line 140, in inspect
    ret = reg(subject)
          ^^^^^^^^^^^^
  File "/home/kirill/easy_refer_bot/.venv/lib/python3.12/site-packages/sqlalchemy/ext/asyncio/engine.py", line 1448, in _no_insp_for_async_conn_yet
    raise exc.NoInspectionAvailable(
sqlalchemy.exc.NoInspectionAvailable: Inspection on an AsyncConnection is currently not supported. Please use ``run_sync`` to pass a callable where it's possible to call ``inspect`` on the passed connection. (Background on this error at: https://sqlalche.me/e/20/xd3s)


как воспроизвести
1. клонировать https://github.com/Yakvenalex/easy_refer_bot
2. pip install -r requirements.txt
3. создать .env поменять конфиг под себя
4. запустить бота

вот статья на хабре откуда я и узнал о боте https://habr.com/ru/articles/822809/
  • Вопрос задан
  • 91 просмотр
Пригласить эксперта
Ответы на вопрос 1
@Everything_is_bad
Ну вот к автору asyncpg_lite и надо идти с этим вопросом.
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы