Answer the question
In order to leave comments, you need to log in
Why does the sqlite error occur?
@bot.message_handler(content_types=['document'])
def handle_docs_photo(message):
try:
user_id = message.from_user.id
username = message.from_user.username
file_info = bot.get_file(message.document.file_id)
downloaded_file = bot.download_file(file_info.file_path)
src = 'images' + message.document.file_name;
with open(f"images/{src}", 'wb') as new_file:
new_file.write(downloaded_file)
con = sqlite3.connect("database.db")
cursor = con.cursor()
cursor.execute(f"ALTER TABLE users ADD COLUMN {src} integer")
cursor.execute(f'UPDATE users SET {src} = "images/{src}" WHERE telegram_id = "{user_id}"')
con.commit()
bot.send_message(message.chat.id, f"<b>Ваши обои приняты!Спасибо.</b>\n", parse_mode='html')
img = open(f"images/{src}", 'rb')
bot.send_message(admin_chat, f'User added new wallpaper!\n\ninfo: @{username} / {user_id} file name - {src}')
bot.send_photo(admin_chat, img)
except Exception as e:
print(str(e))
pass
Answer the question
In order to leave comments, you need to log in
src = 'images' + message.document.file_name;
cursor.execute(f"ALTER TABLE users ADD COLUMN {src} integer")
src = 'images' + message.document.file_name;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question