S
S
szjyakgf2022-03-25 18:42:50
Python
szjyakgf, 2022-03-25 18:42:50

How to avoid mistakes?

Bot on aiogram, you need to remove the column:

@dp.message_handler(commands=['test'])
async def test(message: types.Message):
    conn = sqlite3.connect('db.db')
    cur = conn.cursor()
    number = "md" + str(message.get_args())
    cur.execute("ALTER TABLE users DROP COLUMN '%s'" % number)
    conn.commit()
    await message.reply('готово')

When run in the console, everything works and removes the bars.
But I uploaded it to the hosting and I get an error:
cur.execute("ALTER TABLE users drop column '%s'" % number)
sqlite3.OperationalError: near "drop": syntax error

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2022-03-25
@shurshur

Up until version 3.35 sqlite could not delete columns at all https://sqlite.org/changes.html#version_3_35_0

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question