"VALUES('" + username + "')"
like идет только по полям типа project_name. Где не предусмотрен большой объем текста
The ARP specification [LINK:2] suggests but does not
require a timeout mechanism to invalidate cache entries
when hosts change their Ethernet addresses. The
prevalence of proxy ARP (see Section 2.4 of [INTRO:2])
has significantly increased the likelihood that cache
entries in hosts will become invalid, and therefore
some ARP-cache invalidation mechanism is now required
for hosts. Even in the absence of proxy ARP, a long-
period cache timeout is useful in order to
automatically correct any bad ARP data that might have
been cached.
...
(2) Unicast Poll -- Actively poll the remote host by
periodically sending a point-to-point ARP Request
to it, and delete the entry if no ARP Reply is
received from N successive polls. Again, the
timeout should be on the order of a minute, and
typically N is 2.
Context manager для соединения при выходе из with блока закрывает соединение (зачем вам тут вообще with, кстати?).
Ну и если у вас сутками висит процесс в цикле while True, соединение и само по себе может отвалиться.
Делайте коннект в send_messange()