From 122ec1c9b283776b8f1fea5559d4317bdba5b977 Mon Sep 17 00:00:00 2001 From: Michaƫl Ball Date: Mon, 3 Aug 2015 06:52:00 +0100 Subject: Initially use memory based db, then dump on exit --- models/artist.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'models') 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 -- cgit v1.2.3