mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-24 18:04:32 +02:00
'sqlite-utils triggers' command, closes #218
This commit is contained in:
parent
9a5c92b63e
commit
5b246d17a0
3 changed files with 114 additions and 1 deletions
30
docs/cli.rst
30
docs/cli.rst
|
|
@ -261,7 +261,7 @@ The ``--nl``, ``--csv``, ``--tsv`` and ``--table`` options are all available.
|
|||
Listing views
|
||||
=============
|
||||
|
||||
The `views` command shows any views defined in the database::
|
||||
The ``views`` command shows any views defined in the database::
|
||||
|
||||
$ sqlite-utils views sf-trees.db --table --counts --columns --schema
|
||||
view count columns schema
|
||||
|
|
@ -279,6 +279,34 @@ It takes the same options as the ``tables`` command:
|
|||
* ``--tsv``
|
||||
* ``--table``
|
||||
|
||||
.. _cli_triggers:
|
||||
|
||||
Listing triggers
|
||||
================
|
||||
|
||||
The ``triggers`` command shows any triggers configured for the database::
|
||||
|
||||
% sqlite-utils triggers global-power-plants.db --table
|
||||
name table sql
|
||||
--------------- --------- -----------------------------------------------------------------
|
||||
plants_insert plants CREATE TRIGGER [plants_insert] AFTER INSERT ON [plants]
|
||||
BEGIN
|
||||
INSERT OR REPLACE INTO [_counts]
|
||||
VALUES (
|
||||
'plants',
|
||||
COALESCE(
|
||||
(SELECT count FROM [_counts] WHERE [table] = 'plants'),
|
||||
0
|
||||
) + 1
|
||||
);
|
||||
END
|
||||
|
||||
It defaults to showing triggers for all tables. To see triggers for one or more specific tables pass their names as arguments::
|
||||
|
||||
% sqlite-utils triggers global-power-plants.db plants
|
||||
|
||||
The command takes the same format options as the ``tables`` and ``views`` commands.
|
||||
|
||||
.. _cli_analyze_tables:
|
||||
|
||||
Analyzing tables
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue