A
A
AlexSeley2021-12-23 20:21:00
MySQL
AlexSeley, 2021-12-23 20:21:00

Why is mysql query not working?

gives an error on startup.

@bot.message_handler(commands=['start'])
def start(message):
cursor.execute('INSERT INTO homelessgamebot SET id = ?', (message.chat.id,)) conn.commit
()

, this is for telegram bot. I want to add a new user to the database when sending the "start" command, with id = message.chat.id this is the id of sending the message (start)

Error:
File "C:\Users\Lexa\AppData\Local\Programs\Python\ Python39\lib\site-packages\telebot\__init__.py", line 613, in infinity_polling
self.polling(none_stop=True, timeout=timeout, long_polling_timeout=long_polling_timeout,
File "C:\Users\Lexa\AppData\Local\Programs \Python\Python39\lib\site-packages\telebot\__init__.py", line 660,
self.__threaded_polling(non_stop, interval, timeout, long_polling_timeout, allowed_updates)
File "C:\Users\Lexa\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\__init__.py", line 722, in __threaded_polling
raise e
File "C:\Users\Lexa\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\__init__.py", line 682, in __threaded_polling
self.worker_pool.raise_exceptions()
File "C :\Users\Lexa\AppData\Local\Programs\Python\Python39\lib\site-packages\telebot\util.py", line 135, in raise_exceptions
raise self.exception_info
File "C:\Users\Lexa\AppData\Local \Programs\Python\Python39\lib\site-packages\telebot\util.py", line 87, in run
task(*args, **kwargs)
TypeError: start() takes 0 positional arguments but 1 was given

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-12-23
@Vindicar

AlexSeley , shove the error into the auto-translator, since you don't know English.
telebot tries to call your start() function with one parameter, although from a python point of view it does not accept parameters.
Mysql has nothing to do with the word at all, you can make sure by replacing the contents of start () with pass.
So the question is "why does python think that the start() function takes no parameters".
And here we already need the full code of the bot. Designed as expected, and not just copy-paste.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question