whysocute
@whysocute
Just a boy from Belarus ????????

Где ошибочка в коде? Ошибка:current transaction is aborted??

Я понимаю , что текущая транзакция прерывается,но из за чего?
Странно вообщем.
Еще вчера этой ошибки не было , была с fetchall()
Есть мысли ?
2022-07-29T20:00:20.540233+00:00 heroku[router]: at=info method=POST path="/" host=chelseabottg.herokuapp.com request_id=15d9d94e-ffe0-4dce-91f1-f901580bf0af fwd="91.108.6.125" dyno=web.1 connect=0ms service=96ms status=500 bytes=244 protocol=https
2022-07-29T20:00:20.540413+00:00 app[web.1]: Error handling request
2022-07-29T20:00:20.540422+00:00 app[web.1]: Traceback (most recent call last):
2022-07-29T20:00:20.540423+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
2022-07-29T20:00:20.540424+00:00 app[web.1]:     resp = await request_handler(request)
2022-07-29T20:00:20.540424+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/aiohttp/web_app.py", line 504, in _handle
2022-07-29T20:00:20.540424+00:00 app[web.1]:     resp = await handler(request)
2022-07-29T20:00:20.540425+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/aiohttp/web_urldispatcher.py", line 954, in _iter
2022-07-29T20:00:20.540425+00:00 app[web.1]:     resp = await method()
2022-07-29T20:00:20.540425+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/aiogram/dispatcher/webhook.py", line 139, in post
2022-07-29T20:00:20.540426+00:00 app[web.1]:     results = await self.process_update(update)
2022-07-29T20:00:20.540427+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/aiogram/dispatcher/webhook.py", line 190, in process_update
2022-07-29T20:00:20.540427+00:00 app[web.1]:     return fut.result()
2022-07-29T20:00:20.540428+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/aiogram/dispatcher/handler.py", line 116, in notify
2022-07-29T20:00:20.540429+00:00 app[web.1]:     response = await handler_obj.handler(*args, **partial_data)
2022-07-29T20:00:20.540429+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/aiogram/dispatcher/dispatcher.py", line 256, in process_update
2022-07-29T20:00:20.540429+00:00 app[web.1]:     return await self.message_handlers.notify(update.message)
2022-07-29T20:00:20.540430+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.8/site-packages/aiogram/dispatcher/handler.py", line 116, in notify
2022-07-29T20:00:20.540430+00:00 app[web.1]:     response = await handler_obj.handler(*args, **partial_data)
2022-07-29T20:00:20.540430+00:00 app[web.1]:   File "/app/handlers/admins.py", line 65, in cm_discription
2022-07-29T20:00:20.540430+00:00 app[web.1]:     await add_sql_command(state)
2022-07-29T20:00:20.540431+00:00 app[web.1]:   File "/app/data_base/sqlite_db.py", line 31, in add_sql_command
2022-07-29T20:00:20.540432+00:00 app[web.1]:     cur.execute (
2022-07-29T20:00:20.540432+00:00 app[web.1]: psycopg2.errors.InFailedSqlTransaction: current transaction is aborted, commands ignored until end of transaction block
2022-07-29T20:00:20.540433+00:00 app[web.1]:


from create_bot import bot
import psycopg2
from data_base.config import host , user , password , database



async def sql_start():
    global base , cur
base= psycopg2.connect (
    host=host ,
    user=user ,
    password=password ,
    database=database
)
cur = base.cursor()
if base:
    print ('Я подключился!')
    cur.execute (
    """CREATE TABLE IF NOT EXISTS memories(
        img varchar (50) NOT NULL,
        name varchar (100) PRIMARY KEY,
        discruption varchar (200) NOT NULL);"""
        )
    base.cursor()
    base.commit()

async def add_sql_command(state):
    global base , cur
    async with state.proxy() as data:
             cur.execute (
            """INSERT INTO memories (img , name , discruption) VALUES
            (' ? ',' ? ',' ? ' ); """ , tuple(data.values()))

async def sql_read(message):
    global base , cur
    for ret in cur.execute('SELECT * FROM memories').fetchall():
        await bot.send_photo(message.from_user.id , ret[0], f'{ret[1]}\nОписание:\n{ret[2]}\nНадеюсь вам понравилось воспоминание!')

async def sql_read2():
    global base , cur
    return cur.execute ('SELECT * FROM memories').fetchall()

async def sql_delete_command(data):
    global base , cur
    cur.execute ('DELETE FROM memories WHEN name == ?', (data,))
    base.commit()
  • Вопрос задан
  • 110 просмотров
Пригласить эксперта
Ваш ответ на вопрос

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

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