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 A77937E427; Sun, 8 Jan 2023 06:16:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1673158581; bh=5r5yCCbkr7RWr4eHcqjW8CUSKOlOjn3o5gWwosm+Agg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=miPy66ut9qFqEUsH+GkPbljHfkJ8UZ63pwH3Da7ikHt5qSFPSilfB+GhJlV/GM0pb IaD3FEiCqYNiLmk8onv/AKEdZAZMAwUw7Y4LXumcTk2DCpmxISWvYsy0rfslAwsSf/ N6YRxlmu4t7RoDIWBHOwhhWIsOTnrQQfgd5FNBUMaojsWk2KVwAOtfeMWuya/ownjx iMKvlQqskGOYgox03sUGC4dpwOz+LPG0zoCPa5kyIZ2SETccK6pFfHMkPz27AHM5vV Z8CJcVvrA0xvIzmQxz0qEBZ1x1n3e/vNge8VY07srLU/Jc3jMB1YxtrCVA3hIrca9R 5weZlkIaPYPaw== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v2 09/11] discord: database: Add ping() method for reconnect MySQL Date: Sun, 8 Jan 2023 13:15:41 +0700 Message-Id: <20230108061543.1780-10-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20230108061543.1780-1-kiizuha@gnuweeb.org> References: <20230108061543.1780-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Added 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