mirror of
https://github.com/ankitects/anki.git
synced 2025-11-09 06:07:11 -05:00
make close() idempotent; add isEmpty()
This commit is contained in:
parent
22df2790f9
commit
2a73d58532
1 changed files with 4 additions and 1 deletions
|
|
@ -118,8 +118,8 @@ crt=?, mod=?, scm=?, dty=?, usn=?, ls=?, conf=?""",
|
|||
|
||||
def close(self, save=True):
|
||||
"Disconnect from DB."
|
||||
self.cleanup()
|
||||
if self.db:
|
||||
self.cleanup()
|
||||
if save:
|
||||
self.save()
|
||||
else:
|
||||
|
|
@ -332,6 +332,9 @@ crt=?, mod=?, scm=?, dty=?, usn=?, ls=?, conf=?""",
|
|||
# Cards
|
||||
##########################################################################
|
||||
|
||||
def isEmpty(self):
|
||||
return not self.db.scalar("select 1 from cards limit 1")
|
||||
|
||||
def cardCount(self):
|
||||
return self.db.scalar("select count() from cards")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue