add tests for sqlitemanager util class

+ implement pendulum in date_string_to_time_passed()
+ remove unused bisection_search_string
This commit is contained in:
mungai-njoroge
2023-06-21 12:18:19 +03:00
parent 9d4f7af581
commit 4d310c39c3
10 changed files with 186 additions and 161 deletions
+14 -7
View File
@@ -10,7 +10,7 @@ from .utils import SQLiteManager
class SQLiteArtistMethods:
@staticmethod
def insert_one_artist(cur: Cursor, artisthash: str, colors: str | list[str]):
def insert_one_artist(cur: Cursor, artisthash: str, colors: list[str]):
"""
Inserts a single artist into the database.
"""
@@ -23,16 +23,23 @@ class SQLiteArtistMethods:
cur.execute(sql, (artisthash, colors))
@staticmethod
def get_all_artists():
def get_all_artists(cur_: Cursor = None):
"""
Get all artists from the database and return a generator of Artist objects
"""
sql = """SELECT * FROM artists"""
with SQLiteManager() as cur:
cur.execute(sql)
if not cur_:
with SQLiteManager() as cur:
cur.execute(sql)
for artist in cur.fetchall():
for artist in cur.fetchall():
yield artist
cur.close()
else:
cur_.execute(sql)
for artist in cur_.fetchall():
yield artist
cur.close()