mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 09:24:31 +02:00
table.has_counts_triggers property, refs #219
This commit is contained in:
parent
c265541384
commit
b4f09146d3
4 changed files with 46 additions and 4 deletions
|
|
@ -571,6 +571,20 @@ def enable_counts(path, tables, load_extension):
|
|||
db[table].enable_counts()
|
||||
|
||||
|
||||
@cli.command(name="reset-counts")
|
||||
@click.argument(
|
||||
"path",
|
||||
type=click.Path(exists=True, file_okay=True, dir_okay=False, allow_dash=False),
|
||||
required=True,
|
||||
)
|
||||
@load_extension_option
|
||||
def reset_counts(path, load_extension):
|
||||
"Reset calculated counts in the _counts table"
|
||||
db = sqlite_utils.Database(path)
|
||||
_load_extensions(db, load_extension)
|
||||
db.reset_counts()
|
||||
|
||||
|
||||
def insert_upsert_options(fn):
|
||||
for decorator in reversed(
|
||||
(
|
||||
|
|
|
|||
|
|
@ -1268,6 +1268,16 @@ class Table(Queryable):
|
|||
self.db.conn.executescript(sql)
|
||||
self.db.use_counts_table = True
|
||||
|
||||
@property
|
||||
def has_counts_triggers(self):
|
||||
trigger_names = {
|
||||
"{table}{counts_table}_{suffix}".format(
|
||||
counts_table=self.db._counts_table_name, table=self.name, suffix=suffix
|
||||
)
|
||||
for suffix in ["insert", "delete"]
|
||||
}
|
||||
return trigger_names.issubset(self.triggers_dict.keys())
|
||||
|
||||
def enable_fts(
|
||||
self,
|
||||
columns,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue