mirror of
https://github.com/ankitects/anki.git
synced 2025-11-09 14:17:13 -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):
|
def close(self, save=True):
|
||||||
"Disconnect from DB."
|
"Disconnect from DB."
|
||||||
self.cleanup()
|
|
||||||
if self.db:
|
if self.db:
|
||||||
|
self.cleanup()
|
||||||
if save:
|
if save:
|
||||||
self.save()
|
self.save()
|
||||||
else:
|
else:
|
||||||
|
|
@ -332,6 +332,9 @@ crt=?, mod=?, scm=?, dty=?, usn=?, ls=?, conf=?""",
|
||||||
# Cards
|
# Cards
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
|
def isEmpty(self):
|
||||||
|
return not self.db.scalar("select 1 from cards limit 1")
|
||||||
|
|
||||||
def cardCount(self):
|
def cardCount(self):
|
||||||
return self.db.scalar("select count() from cards")
|
return self.db.scalar("select count() from cards")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue