GeezerVison is showing github.com — Support completion for sqlite3 command-line interface · Issue #133390 · python/cpython
Support completion for sqlite3 command-line interface #133390DescriptionFeature or enhancement
Proposal:
Current sqlite3 CLI lacks tab-completion feature. Hope it can be supported to improve usability.
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
ActivityStanFromIreland commented on May 4, 2025
This is a minor feature
I would disagree, this would presumably require quite a lot of work to implement and then maintain. Maybe this should be discussion on discourse first? tanloong commented on May 4, 2025 ContributorAuthor More actions Right. But I think for the moment we can support basic completion which takes not much work but gives big experience enhancement. StanFromIreland commented on May 4, 2025 #133393 introduces keyword expansion, but what about name expansion (the part I was originally worried about)? tanloong commented on May 4, 2025 ContributorAuthor More actions Can we get the name list when connecting to a disk-file database, merge it with keyword list as completion candidates? Also the name list need to be updated on deletion/creation of table/column.
import sqlite3
def get_names(db_path):
ret = []
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;")
tables = [row[0] for row in cursor.fetchall()] # get table names
ret.extend(tables)
for table in tables:
cursor.execute(f"PRAGMA table_info({table})")
ret.extend(row[1] for row in cursor.fetchall()) # get column names
conn.close()
return ret
db_path = '/path/to/db.db'
list_of_names = get_names(db_path)StanFromIreland commented on May 5, 2025 @hugovk (BDFC ;-) out of curiosity, is this on your list for colorising, it is a good candidate ? I’d take a stab at it once this is merged. hugovk commented on May 5, 2025 StanFromIreland commented on May 5, 2025
sounds like a good candidate.
Opened #133447 :-) Reacted by Hugo van Kemenade encukou commented on Jun 7, 2025 Unfortunately, there are issues on the buildbots found before, e.g. here.
I spent some time investigating this, but couldn't reproduce locally or in a container. Next week I'll ask the buildbot owner for SSH access to try and see what's going on, but that's better done after the weekend.
The buildbots are only effective if they're kept passing, so I need to revert the commit temporarily. added a commit that references this issue on Oct 24, 2025gh-133390: sqlite3 CLI completion for tables, columns, indices, trigg… encukou commented on Oct 24, 2025 Thank you for the completion, @tanloong!
Do you plan to add more, or should we close the issue? tanloong commented on Oct 24, 2025 ContributorAuthor More actions Thanks a lot to everyone for all the help and review!
There is no more I plan to add. I will close this issue. StanFromIreland commented on Oct 24, 2025 Developer thought completion? ;-)
Thanks for all of your work in this!
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|