mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-08 01:24:20 +02:00
Fix count_where() raising OperationalError on nonexistent tables
rows_where() and delete_where() already return gracefully when called on a table that does not exist yet; count_where() now does the same by returning 0 instead of propagating OperationalError from SQLite.
This commit is contained in:
parent
fcfccea813
commit
4fd34b85ad
2 changed files with 8 additions and 0 deletions
|
|
@ -2023,6 +2023,8 @@ class Queryable:
|
|||
:param where_args: Parameters to use with that fragment - an iterable for ``id > ?``
|
||||
parameters, or a dictionary for ``id > :id``
|
||||
"""
|
||||
if not self.exists():
|
||||
return 0
|
||||
sql = f"select count(*) from {quote_identifier(self.name)}"
|
||||
if where is not None:
|
||||
sql += " where " + where
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue