diff options
Diffstat (limited to 'models')
-rw-r--r-- | models/artist.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/models/artist.py b/models/artist.py index 1ac27d5..1afd516 100644 --- a/models/artist.py +++ b/models/artist.py @@ -131,3 +131,25 @@ class Artist: ) return artists + + def all(order="sortname", direction="ASC", limit=None, offset=None): + db = DbManager() + cursor = db.cursor() + artists = [] + + select_string = """SELECT * FROM artist ORDER BY %s %s""" % (order, + direction) + + if limit is not None and offset is not None: + select_string = " ".join((select_string, + "LIMIT %s OFFSET %s" % (limit, offset))) + + result = cursor.execute(select_string) + + for row in result: + artists.append( + Artist(id=row[0], name=row[1], sortname=row[2], + musicbrainz_artistid=row[3]) + ) + + return artist |