rlhelinski / musicbrainz-catalog

Python code for cataloging your music collection cross-referenced with MusicBrainz
GNU General Public License v2.0
2 stars 0 forks source link

Make it Easier to Find Checked Out Releases #75

Open rlhelinski opened 6 years ago

rlhelinski commented 6 years ago
rlhelinski commented 6 years ago

A list of all the releases that have ever been checked out can be compiled with: c.cm.executeAndFetch('select distinct(release) from checkout_events')

rlhelinski commented 6 years ago

A list of only releases that are currently checked out can be compiled with:

relIds = c.cm.executeAndFetch('select distinct(release) from checkout_events')
for relId in relIds:
    if c.getCheckOutStatus(relId[0]):
        print (relId[0], c.getReleaseArtist(relId[0]), c.getReleaseTitle(relId[0]), c.getCheckOutStatus(relId[0]))
rlhelinski commented 6 years ago
sqlite> alter table releases add column checkedout REFERENCES checkout_events(ROWID);

Then, to populate this new column as appropriate:

results = c.cm.executeAndFetch('select distinct(release), rowid from checkout_events')
for relId, rowId in results:
    if c.getCheckOutStatus(relId):
        print (relId, rowId, c.getReleaseArtist(relId), c.getReleaseTitle(relId), c.getCheckOutStatus(relId))
        c.cm.execute('update releases set checkedout = % where id = %', (rowId, relId))