mirror of
https://github.com/beetbox/beets.git
synced 2025-12-15 21:14:19 +01:00
a couple more cursor closings
This commit is contained in:
parent
8341dee3ab
commit
e5e11503ad
2 changed files with 9 additions and 4 deletions
|
|
@ -959,6 +959,8 @@ class Library(BaseLibrary):
|
|||
return it.next()
|
||||
except StopIteration:
|
||||
return None
|
||||
finally:
|
||||
it.close()
|
||||
|
||||
def get_album(self, item_or_id):
|
||||
"""Given an album ID or an item associated with an album,
|
||||
|
|
@ -976,8 +978,10 @@ class Library(BaseLibrary):
|
|||
'SELECT * FROM albums WHERE id=?',
|
||||
(album_id,)
|
||||
)
|
||||
record = c.fetchone()
|
||||
c.close()
|
||||
try:
|
||||
record = c.fetchone()
|
||||
finally:
|
||||
c.close()
|
||||
if record:
|
||||
return Album(self, dict(record))
|
||||
|
||||
|
|
|
|||
|
|
@ -889,8 +889,9 @@ class Server(BaseServer):
|
|||
|
||||
statement = 'SELECT COUNT(DISTINCT artist), ' \
|
||||
'COUNT(DISTINCT album) FROM items'
|
||||
c = self.lib.conn.cursor()
|
||||
result = c.execute(statement).fetchone()
|
||||
c = self.lib.conn.execute(statement)
|
||||
result = c.fetchone()
|
||||
c.close()
|
||||
artists, albums = result[0], result[1]
|
||||
|
||||
yield (u'artists: ' + unicode(artists),
|
||||
|
|
|
|||
Loading…
Reference in a new issue