summaryrefslogtreecommitdiffstats
path: root/litecli/packages
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-06-19 06:58:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-06-19 06:58:30 +0000
commite6b4d00e3a586be753c3d457c5153380392bda32 (patch)
treefbc8f90eeef85df9cb68bc200fe801f1eba55c4d /litecli/packages
parentReleasing debian version 1.8.0-1. (diff)
downloadlitecli-e6b4d00e3a586be753c3d457c5153380392bda32.tar.xz
litecli-e6b4d00e3a586be753c3d457c5153380392bda32.zip
Merging upstream version 1.9.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'litecli/packages')
-rw-r--r--litecli/packages/completion_engine.py4
-rw-r--r--litecli/packages/special/dbcommands.py53
2 files changed, 37 insertions, 20 deletions
diff --git a/litecli/packages/completion_engine.py b/litecli/packages/completion_engine.py
index 0397857..0e2a30f 100644
--- a/litecli/packages/completion_engine.py
+++ b/litecli/packages/completion_engine.py
@@ -105,14 +105,14 @@ def suggest_special(text):
if cmd in ["\\f", "\\fs", "\\fd"]:
return [{"type": "favoritequery"}]
- if cmd in ["\\d", "\\dt", "\\dt+", ".schema"]:
+ if cmd in ["\\d", "\\dt", "\\dt+", ".schema", ".indexes"]:
return [
{"type": "table", "schema": []},
{"type": "view", "schema": []},
{"type": "schema"},
]
- if cmd in ["\\.", "source", ".open"]:
+ if cmd in ["\\.", "source", ".open", ".read"]:
return [{"type": "file_name"}]
if cmd in [".import"]:
diff --git a/litecli/packages/special/dbcommands.py b/litecli/packages/special/dbcommands.py
index a7eaa0c..203e1a8 100644
--- a/litecli/packages/special/dbcommands.py
+++ b/litecli/packages/special/dbcommands.py
@@ -111,6 +111,41 @@ def list_databases(cur, **_):
@special_command(
+ ".indexes",
+ ".indexes [tablename]",
+ "List indexes.",
+ arg_type=PARSED_QUERY,
+ case_sensitive=True,
+ aliases=("\\di",),
+)
+def list_indexes(cur, arg=None, arg_type=PARSED_QUERY, verbose=False):
+ if arg:
+ args = ("{0}%".format(arg),)
+ query = """
+ SELECT name FROM sqlite_master
+ WHERE type = 'index' AND tbl_name LIKE ? AND name NOT LIKE 'sqlite_%'
+ ORDER BY 1
+ """
+ else:
+ args = tuple()
+ query = """
+ SELECT name FROM sqlite_master
+ WHERE type = 'index' AND name NOT LIKE 'sqlite_%'
+ ORDER BY 1
+ """
+
+ log.debug(query)
+ cur.execute(query, args)
+ indexes = cur.fetchall()
+ status = ""
+ if cur.description:
+ headers = [x[0] for x in cur.description]
+ else:
+ return [(None, None, None, "")]
+ return [(None, indexes, headers, status)]
+
+
+@special_command(
".status",
"\\s",
"Show current settings.",
@@ -203,24 +238,6 @@ def describe(cur, arg, **_):
@special_command(
- ".read",
- ".read path",
- "Read input from path",
- arg_type=PARSED_QUERY,
- case_sensitive=True,
-)
-def read_script(cur, arg, **_):
- args = shlex.split(arg)
- if len(args) != 1:
- raise TypeError(".read accepts exactly one path")
- path = args[0]
- with open(path, "r") as f:
- script = f.read()
- cur.executescript(script)
- return [(None, None, None, "")]
-
-
-@special_command(
".import",
".import filename table",
"Import data from filename into an existing table",