Здравствуйте, подключаюсь к базе данных через библиотеку pymysql, отправляю первый запрос, все отправляется пылюсь еще раз отправить выдает ошибку pymysql.err.InterfaceError: (0, '').
При этом использую еще библиотеку threading. Подскажите пожалуйста!
connect = pymysql.connect('lockhost', 'login, 'password', 'db',cursorclass=pymysql.cursors.DictCursor)
class commands:
def notesAll(self):
try:
with connect:
cursor = connect.cursor()
cursor.execute("""SELECT * FROM Notes""")
result = cursor.fetchall()
array_id = []
print(result)
for all_chats in result:
array_id.append(all_chats)
for i in range(len(array_id)):
day = datetime.now().day
month = datetime.now().month
year = datetime.now().year
year = f'{year}'
hour = datetime.now().hour
minute = datetime.now().minute
date = datetime.strptime(f'{day}.{month}.{year[0:2]} {hour}:{minute}', "%d.%m.%y %H:%M")
print(array_id[i]['dateTo'])
write_date = array_id[i]['dateTo'].split(' ')[0].split('.')[0] + '.' \
+ array_id[i]['dateTo'].split(' ')[0].split('.')[1] + '.' + \
array_id[i]['dateTo'].split(' ')[0].split('.')[2][0:2] + ' ' \
+ array_id[i]['dateTo'].split(' ')[1]
date1 = datetime.strptime(write_date, "%d.%m.%y %H:%M")
nu = ''
if date > date1:
nu = '⚠️ Врмя прошло!'
if array_id[i]['dateChange'] == 0:
change = ''
else:
change = f" Изменили -- {array_id[i]['dateChange']}\n"
msga = ' Информация о заметках!\n' \
f" ID -- {array_id[i]['id']}\n" \
f" Дата -- {array_id[i]['dateIn']} - {array_id[i]['dateTo']}\n" \
f'{change}' \
f" Создал заметку -- [id{array_id[i]['userId']}|{send.user_get(self, array_id[i]['userId'])}]\n" \
f" Текст -- {array_id[i]['text']}\n\n{nu}"
send.messages(self, msga, self.user_id)
if array_id == []:
msga = 'Нет заметок =('
send.messages(self, msga, self.user_id)
except Exception as error:
logging.exception(error)
class Bot:
def __init__(self, vk, group, longpoll):
self.vk = vk
self.group = group
self.longpoll = longpoll
thread1 = Thread(target=self.times, args=())
thread1.start()
def Running(self):
try:
while True:
for event in self.longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
self.event = event
self.chat_id = event.object.peer_id
self.user_id = event.object.from_id
if self.user_id in creator_id:
self.Commands()
except Exception as error:
logging.exception(error)
def Commands(self):
try:
body = self.event.object.text
body = self.delout(body)
body = body
if body[0:len('заметки') + 0:].lower() == 'заметки':
commands.notesAll(self)
except Exception as error:
logging.exception(error)
run = Bot(vk, group, longpoll)
thread1 = Thread(target=run.Running, args=())
thread1.start()