Applied auto pep 8 changes
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Mapping, Any
|
||||
from typing import Mapping, Any
|
||||
import sqlite3
|
||||
import os
|
||||
|
||||
|
||||
class DatabaseController(ABC):
|
||||
__data_dir = "./data/"
|
||||
__db_name = "wmgzon.db"
|
||||
@@ -13,13 +14,13 @@ class DatabaseController(ABC):
|
||||
|
||||
__sqlitefile = __data_dir + __db_name
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self._conn = None
|
||||
try:
|
||||
# Creates a connection and specifies a flag to parse all types back down into
|
||||
# Python declared types e.g. date & time
|
||||
self._conn = sqlite3.connect(self.__sqlitefile, detect_types=sqlite3.PARSE_DECLTYPES)
|
||||
self._conn = sqlite3.connect(
|
||||
self.__sqlitefile, detect_types=sqlite3.PARSE_DECLTYPES)
|
||||
except sqlite3.Error as e:
|
||||
# Close the connection if still open
|
||||
if self._conn:
|
||||
@@ -27,17 +28,18 @@ class DatabaseController(ABC):
|
||||
print(e)
|
||||
|
||||
def __del__(self):
|
||||
if self._conn != None:
|
||||
if self._conn != None:
|
||||
self._conn.close()
|
||||
|
||||
""" Takes a dictionary of fields and returns the object
|
||||
with those fields populated """
|
||||
|
||||
def new_instance(self, of: type, with_fields: Mapping[str, Any]):
|
||||
obj = of.__new__(of)
|
||||
for attr, value in with_fields.items():
|
||||
setattr(obj, attr, value)
|
||||
return obj
|
||||
|
||||
|
||||
"""
|
||||
Set of CRUD methods to allow for Data manipulation on the backend
|
||||
"""
|
||||
@@ -53,7 +55,7 @@ class DatabaseController(ABC):
|
||||
@abstractmethod
|
||||
def update(self):
|
||||
pass
|
||||
|
||||
|
||||
@abstractmethod
|
||||
def delete(self):
|
||||
pass
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user