From cc6d58312fd8f809ef3669703ee744fe7ef73167 Mon Sep 17 00:00:00 2001 From: Robert Goldmann <deadlocker@gmx.de> Date: Sat, 16 Jan 2021 22:23:43 +0100 Subject: [PATCH] cleanup old classes --- src/logic/database/DatabaseAccess.py | 57 ---------------------------- src/logic/database/__init__.py | 0 2 files changed, 57 deletions(-) delete mode 100644 src/logic/database/DatabaseAccess.py delete mode 100644 src/logic/database/__init__.py diff --git a/src/logic/database/DatabaseAccess.py b/src/logic/database/DatabaseAccess.py deleted file mode 100644 index 408c682..0000000 --- a/src/logic/database/DatabaseAccess.py +++ /dev/null @@ -1,57 +0,0 @@ -import abc -import logging -import sqlite3 -from abc import ABC -from enum import Enum - -from logic import Constants -from logic.BackupService import BackupService - -LOGGER = logging.getLogger(Constants.APP_NAME) - - -class FetchType(Enum): - NONE = 1 - ONE = 2 - ALL = 3 - CREATE = 4 - - -class DatabaseAccess(ABC): - DATE_FORMAT = '%Y-%m-%d %H:%M:%S' - - @staticmethod - def namedtuple_factory(cursor, row): - """ - Returns sqlite rows as dicts. - """ - d = {} - for idx, col in enumerate(cursor.description): - d[col[0]] = row[idx] - return d - - def __init__(self, databasePath, backupService: BackupService): - self._databasePath = databasePath - self._backupService = backupService - - @abc.abstractmethod - def create_table(self): - pass - - def _query(self, query, *args, fetch_type=FetchType.ALL): - connection = sqlite3.connect(self._databasePath) - connection.row_factory = DatabaseAccess.namedtuple_factory - - with connection: - cursor = connection.cursor() - try: - cursor.execute(query, args) - - if fetch_type == FetchType.ONE: - return cursor.fetchone() - if fetch_type == FetchType.ALL: - return cursor.fetchall() - if fetch_type == FetchType.NONE: - self._backupService.perform_modification() - finally: - cursor.close() diff --git a/src/logic/database/__init__.py b/src/logic/database/__init__.py deleted file mode 100644 index e69de29..0000000 -- GitLab