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 5C8A280BE8; Tue, 13 Sep 2022 10:26:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1663064786; bh=iGAlnBDLBD75g/3WiSFXf7Nu5cAbKNhOJEuYkDQcQv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pwrfKvrMPrB16OJ2kMyGSAls55s5ZKF439R95uTlrfv3YOx2/N9KjvsaEVzHUdvF+ u9eVlhhOkWDJ1hEYGvBhTXzR0eUnoqniV4YnBztPm1LQe25xeetfvnMKOW7lC3Sws/ FU+l/DGKsUep+SMfrvK9KKG5OAeEWVQwb/Qa0RFftdJE+4yLP/f6cvj1fE7VGVT9up ue/e03k2SKdFFcR4N4BoiDim7EqSAQCclkglrbsYqbfbeEUGcNZmIuywnUTmXbN0yl oQ0M2sXU1s3o6iq7rBSvJTXbMxhaNDrdw3Q3+0/z36rVzElxFVajxag9HsaXKOSowr ezzRmWCsq17lg== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [RFC PATCH v2 13/17] discord: Add initial Discord bot database instance Date: Tue, 13 Sep 2022 17:24:54 +0700 Message-Id: <20220913102458.615-14-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20220913102458.615-1-kiizuha@gnuweeb.org> References: <20220913102458.615-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