From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [101.128.126.135]) by gnuweeb.org (Postfix) with ESMTPSA id 687F47E5F8; Sun, 8 Jan 2023 08:08:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1673165298; bh=13GFOxiED0LWgkYUfdrLYkghp9H3IWLkzBeBOOmm0m0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VA2BYzVAPfyY29YWQNfD7SUCA2Wnf35aJOt0JutiVVVHcLEK4Yt8fXNrNFyIztCB+ cFPW2yZXvaM7ZZaBzVsdDFv12eZPdWvjLJ4Efxjx2/xGQYI3mGQr6CedZ9tWm2fIyz oF1vIoRe9mXRgbgNCf+Atl42kJI7YPmJ3/04doIcBY+esGvRVHWwISY4MY4kogQfzm XWcWkXy5RyN2MeLiJEjPrrcAwCmhKZFYK70U/g+FSt9cRbq9J9E0FdQF2pq0WZa5GA QSCgZF3m++9yq66jfiEQbsGkseBjyOrfOTLBNSzG2mSIE/GFvJRoJS+A2mJZgZy//K 78SRzwspv7XYQ== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v3 09/11] discord: database: Add ping() method for reconnect MySQL Date: Sun, 8 Jan 2023 15:07:39 +0700 Message-Id: <20230108080741.1914-10-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20230108080741.1914-1-kiizuha@gnuweeb.org> References: <20230108080741.1914-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Add ping() in the Discord database core.py for reconnecting the MySQL database. This function is to reconnect the MySQL connection. Signed-off-by: Muhammad Rizki --- daemon/dscord/database/core.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/daemon/dscord/database/core.py b/daemon/dscord/database/core.py index c34d7a8..c8826bb 100644 --- a/daemon/dscord/database/core.py +++ b/daemon/dscord/database/core.py @@ -15,6 +15,12 @@ class DB(DBMethods): self.cur = self.conn.cursor(buffered=True) + def ping(self, reconnect=True, attempts=3, delay=3): + self.conn.ping(reconnect=reconnect, attempts=attempts, + delay=delay) + self.cur = self.conn.cursor(buffered=True) + + def __del__(self): self.cur.close() self.conn.close() -- Muhammad Rizki