(Refactor) remove fucntion for creating DB file.

main
KKlochko 2 years ago
parent 222bf53b25
commit 1a4405fbbc

@ -29,3 +29,5 @@
Added TOML configuration file. Added TOML configuration file.
Updated paths of files and folders. Updated paths of files and folders.
Updated my name to my fullname and release years. Updated my name to my fullname and release years.
** 1.0.2 <2023-01-15>
Refactor the database class and remove function for the creating file.

@ -29,22 +29,8 @@ class DataBase:
def __init__(self, PATH: str = "user.db", TABLE: str = "animes"): def __init__(self, PATH: str = "user.db", TABLE: str = "animes"):
"""Initialising the connection information.""" """Initialising the connection information."""
self.PATH, self.TABLE = PATH, TABLE self.PATH, self.TABLE = PATH, TABLE
self.database_is_exists()
self.create_table(self.TABLE) self.create_table(self.TABLE)
def database_is_exists(self):
"""Creates DB file if not exists."""
try:
f = open(self.PATH, 'r')
f.close()
except FileNotFoundError:
f = open(self.PATH, 'w')
f.close()
except Exception as e:
print(f"{e=}")
finally:
pass
def create_table(self, table): def create_table(self, table):
"""Create a table in the DB.""" """Create a table in the DB."""
connect = sqlite3.connect(self.PATH) connect = sqlite3.connect(self.PATH)

Loading…
Cancel
Save