break settings.py into classes

This commit is contained in:
geoffrey45
2023-03-26 08:25:00 +03:00
parent 79029ae346
commit 357afeb700
22 changed files with 102 additions and 96 deletions
+2 -2
View File
@@ -6,7 +6,7 @@ import sqlite3
from pathlib import Path
from sqlite3 import Connection as SqlConn
from app.settings import APP_DB_PATH
from app.settings import Db
def create_connection(db_file: str) -> SqlConn:
@@ -22,7 +22,7 @@ def get_sqlite_conn():
It opens a connection to the database
:return: A connection to the database.
"""
return create_connection(APP_DB_PATH)
return create_connection(Db.APP_DB_PATH)
def create_tables(conn: SqlConn, sql_query: str):
+3 -3
View File
@@ -7,7 +7,7 @@ from sqlite3 import Connection, Cursor
import time
from app.models import Album, Playlist, Track
from app.settings import APP_DB_PATH, USERDATA_DB_PATH
from app.settings import Db
def tuple_to_track(track: tuple):
@@ -78,10 +78,10 @@ class SQLiteManager:
if self.conn is not None:
return self.conn.cursor()
db_path = APP_DB_PATH
db_path = Db.APP_DB_PATH
if self.userdata_db:
db_path = USERDATA_DB_PATH
db_path = Db.USERDATA_DB_PATH
self.conn = sqlite3.connect(
db_path,