Какието проблемы с cursor.execute. Все работало и вдруг ошибка
даже в таком коде
вот лог ошилбки
сам листинг вот:
даже в таком коде
Python:
sql_query = f"Select * from users"
print (sql_query)
cursor = db.cursor()
cursor.execute(sql_query)
вот лог ошилбки
Код:
2020-04-23 16:41:21,015 (util.py:66 WorkerThread1) ERROR - TeleBot: "InterfaceError occurred, args=("(0, '')",)
Traceback (most recent call last):
File "D:\Install\python\lib\site-packages\telebot\util.py", line 60, in run
task(*args, **kwargs)
File "D:/Develop/Python/webkor_bot/main.py", line 32, in start
cursor.execute(sql_query)
File "D:\Install\python\lib\site-packages\pymysql\cursors.py", line 170, in execute
result = self._query(query)
File "D:\Install\python\lib\site-packages\pymysql\cursors.py", line 328, in _query
conn.query(q)
File "D:\Install\python\lib\site-packages\pymysql\connections.py", line 516, in query
self._execute_command(COMMAND.COM_QUERY, sql)
File "D:\Install\python\lib\site-packages\pymysql\connections.py", line 750, in _execute_command
raise err.InterfaceError("(0, '')")
pymysql.err.InterfaceError: (0, '')
"
Traceback (most recent call last):
File "D:/Develop/Python/webkor_bot/main.py", line 50, in <module>
bot.polling(none_stop=True)
File "D:\Install\python\lib\site-packages\telebot\__init__.py", line 392, in polling
self.__threaded_polling(none_stop, interval, timeout)
File "D:\Install\python\lib\site-packages\telebot\__init__.py", line 416, in __threaded_polling
self.worker_pool.raise_exceptions()
File "D:\Install\python\lib\site-packages\telebot\util.py", line 109, in raise_exceptions
six.reraise(self.exc_info[0], self.exc_info[1], self.exc_info[2])
File "D:\Install\python\lib\site-packages\six.py", line 703, in reraise
raise value
File "D:\Install\python\lib\site-packages\telebot\util.py", line 60, in run
task(*args, **kwargs)
File "D:/Develop/Python/webkor_bot/main.py", line 32, in start
cursor.execute(sql_query)
File "D:\Install\python\lib\site-packages\pymysql\cursors.py", line 170, in execute
result = self._query(query)
File "D:\Install\python\lib\site-packages\pymysql\cursors.py", line 328, in _query
conn.query(q)
File "D:\Install\python\lib\site-packages\pymysql\connections.py", line 516, in query
self._execute_command(COMMAND.COM_QUERY, sql)
File "D:\Install\python\lib\site-packages\pymysql\connections.py", line 750, in _execute_command
raise err.InterfaceError("(0, '')")
pymysql.err.InterfaceError: (0, '')
сам листинг вот:
Python:
db = pymysql.connect('localhost', 'chellas', '123', 'superbot')
bot = telebot.TeleBot(TOKEN)
print('Start Server')
keyboard1 = telebot.types.ReplyKeyboardMarkup(True, True)
keyboard1.row('Мои боты', 'Тарифы')
@bot.message_handler(commands=['start'])
def start(message):
send_mess = f"<b>Hi {message.from_user.first_name}</b>\n" \
f"Добро пожаловать на <b>SuperBot</b>"
bot.send_message(message.chat.id, send_mess, parse_mode='html', reply_markup=keyboard1)
send_mess2= f"Твой баланс:"
bot.send_message(message.chat.id, send_mess2)
user_id = message.from_user.id
username = message.from_user.username
print(username)
sql_query = f"""insert into users (telegram_id) values (23)"""
cursor = db.cursor()
cursor.execute(sql_query)
cursor.close()
db.commit()
print ("INSERT SECCESSFULLY")
db.close()
Последнее редактирование: