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,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [101.128.125.100]) by gnuweeb.org (Postfix) with ESMTPSA id 1E7A580D4E; Mon, 19 Sep 2022 07:27:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1663572451; bh=iGAlnBDLBD75g/3WiSFXf7Nu5cAbKNhOJEuYkDQcQv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oYbN2W6HziGeSf7GedGGkfH7o6B2jM5BK6wLdm3/k4KvUdxzOlx3D740EC01c7v9h hLB0Wp0wjlEJRajES/LtnQBAqKZSI+p0zDYFYlgfbmIsLGt+iZjFnLRaNdBK7SAiO9 DhsdFBP4LLLWQCYW1opWO1YID2VTl2oI2G+u/PLdUtCAuIWUG6uNycv0KyYPmlTX0P etlW5PHyKFAibXYWkN+T26AzU3eKUdlVwUNHUaGzmx/mD1QIKYLdmMNH9w8RwN4emH mkgQPmn7yFalcy4AWc2/J15+Lnmea/vXObRG9w819iShgWLPLMtJkPmG/Krv0VWHgw YqX+mS7yYw83w== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [RFC PATCH v3 13/17] discord: Add initial Discord bot database instance Date: Mon, 19 Sep 2022 14:26:37 +0700 Message-Id: <20220919072641.996-14-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20220919072641.996-1-kiizuha@gnuweeb.org> References: <20220919072641.996-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Adding a Discord bot database class instance. Signed-off-by: Muhammad Rizki --- daemon/dscord/database/__init__.py | 6 ++++++ daemon/dscord/database/core.py | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 daemon/dscord/database/__init__.py create mode 100644 daemon/dscord/database/core.py diff --git a/daemon/dscord/database/__init__.py b/daemon/dscord/database/__init__.py new file mode 100644 index 0000000..c720e19 --- /dev/null +++ b/daemon/dscord/database/__init__.py @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (C) 2022 Muhammad Rizki +# + +from .core import DB diff --git a/daemon/dscord/database/core.py b/daemon/dscord/database/core.py new file mode 100644 index 0000000..1a25388 --- /dev/null +++ b/daemon/dscord/database/core.py @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (C) 2022 Muhammad Rizki +# Copyright (C) 2022 Ammar Faizi +# + + +class DB: + def __init__(self, conn): + self.conn = conn + self.conn.autocommit = True + self.cur = self.conn.cursor(buffered=True) + + + def __del__(self): + self.cur.close() + self.conn.close() -- Muhammad Rizki