mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-06-06 19:25:34 +00:00

+ fix: sqlite3.ProgrammingError: Cannot operate on a closed cursor on ProcessAlbumColors() + move processing artist images from periodic_scans to Populate + bump hash string limit from 7 to 10 + add last_mod property to database + fix: TypeError: '<' not supported between instances of 'int' and 'str' on album page
39 lines
935 B
Python
39 lines
935 B
Python
"""
|
|
Contains methods for reading and writing to the sqlite artists database.
|
|
"""
|
|
|
|
import json
|
|
from sqlite3 import Cursor
|
|
|
|
from .utils import SQLiteManager
|
|
|
|
|
|
class SQLiteArtistMethods:
|
|
@staticmethod
|
|
def insert_one_artist(cur: Cursor, artisthash: str, colors: str | list[str]):
|
|
"""
|
|
Inserts a single artist into the database.
|
|
"""
|
|
sql = """INSERT OR REPLACE INTO artists(
|
|
artisthash,
|
|
colors
|
|
) VALUES(?,?)
|
|
"""
|
|
colors = json.dumps(colors)
|
|
cur.execute(sql, (artisthash, colors))
|
|
|
|
@staticmethod
|
|
def get_all_artists():
|
|
"""
|
|
Get all artists from the database and return a generator of Artist objects
|
|
"""
|
|
sql = """SELECT * FROM artists"""
|
|
|
|
with SQLiteManager() as cur:
|
|
cur.execute(sql)
|
|
|
|
for artist in cur.fetchall():
|
|
yield artist
|
|
|
|
cur.close()
|