summaryrefslogtreecommitdiff
path: root/models
diff options
context:
space:
mode:
authorMichaël Ball <michael.ball@gmail.com>2015-08-03 06:52:00 +0100
committerMichaël Ball <michael.ball@gmail.com>2015-08-03 06:52:00 +0100
commit122ec1c9b283776b8f1fea5559d4317bdba5b977 (patch)
tree874f4a1e2644f165f08295e56e150be9e3cafe97 /models
parent35a21c4d12ae85aed699d4117ebbdb4c510ad40f (diff)
Initially use memory based db, then dump on exit
Diffstat (limited to 'models')
-rw-r--r--models/artist.py22
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