|
|
@ -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)
|
|
|
|