Skip to content

Improve .help in the sqlite3 CLI #133934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tanloong opened this issue May 12, 2025 · 2 comments
Open

Improve .help in the sqlite3 CLI #133934

tanloong opened this issue May 12, 2025 · 2 comments
Labels
stdlib Python modules in the Lib dir topic-sqlite3 type-feature A feature request or enhancement

Comments

@tanloong
Copy link
Contributor

tanloong commented May 12, 2025

Feature or enhancement

Proposal:

The .help command in the sqlite3 CLI does not give much information. It only shows a brief message:

sqlite> .help
Enter SQL code and press enter.

It would be better if .help displayed a list of available commands, and .help <command> showed detailed help for that specific command.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

@tanloong tanloong added the type-feature A feature request or enhancement label May 12, 2025
@picnixz picnixz added the stdlib Python modules in the Lib dir label May 15, 2025
@StanFromIreland
Copy link
Contributor

We only need help for two commands, how about we hard-code it? I wrote a patch which can be seen below.

Subject: [PATCH] Expand help
---
Index: Lib/sqlite3/__main__.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/Lib/sqlite3/__main__.py b/Lib/sqlite3/__main__.py
--- a/Lib/sqlite3/__main__.py	(revision 0df15d0d4d55dcf7b7a7f4b2985bf84fd092d257)
+++ b/Lib/sqlite3/__main__.py	(date 1749219376897)
@@ -63,7 +63,10 @@
                 case "version":
                     print(f"{sqlite3.sqlite_version}")
                 case "help":
-                    print("Enter SQL code and press enter.")
+                    t = theme.syntax
+                    print(f"Enter SQL code or one of the below commands, and press enter.\n"
+                          f"{t.builtin}.version{t.reset}    Print the SQLite version\n"
+                          f"{t.builtin}.quit{t.reset}       Exit the CLI, equivalent to CTRL-D\n")
                 case "quit":
                     sys.exit(0)
                 case "":

What do you think @erlend-aasland of this approach?

@erlend-aasland
Copy link
Contributor

SGTM, Stan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir topic-sqlite3 type-feature A feature request or enhancement
Projects
Status: No status
Development

No branches or pull requests

5 participants