D
D
Dmitry2022-02-09 17:35:35
Python
Dmitry, 2022-02-09 17:35:35

TypeError: function takes at most 2 arguments (3 given) how to fix?

I create a base for id and file_id but an error occurred, the base was created, but the id and file_id are empty there, although I pressed start in the bot and had to write down my telegram id.
6203d0ba2a4ff323710015.jpeg

import sqlite3
from sqlite3 import connect
import cursor as cursor
import telebot

API_TOKEN = 'moy_token'

bot = telebot.TeleBot(API_TOKEN)

@bot.message_handler(commands=['start'])
def start(message):
    connect = sqlite3.connect('users.db')
    cursor = connect.cursor()

    cursor.execute("""CREATE TABLE IF NOT EXISTS username_id( 
    id INTEGER,
    file_id INTEGER
    )""")

    connect.commit()

    user_id = ["message.chat.id"]
    file_id = ["message.photo.file_id"]
    cursor.execute("INSERT INTO username_id VALUES(?,?);",user_id, file_id)
    connect.commit()

bot.infinity_polling()


I watched the video and there the person said, if there is one field, then one question mark, I wrote 2 and still an error.
2 The question is how to register so that the photos are recorded in the database by the file_id parameter, maybe I somehow registered it wrong and therefore the error.

cursor.execute("INSERT INTO username_id VALUES(?,?);",user_id, file_id)
TypeError: function takes at most 2 arguments (3 given)

Мне писали, что нужно MediaGroup и как к file_id это прописать.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2022-02-09
@dmitriy8720

cursor.execute("INSERT INTO username_id VALUES(?,?);",(user_id, file_id))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question