-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Support completion for sqlite3 command-line interface #133390
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
Comments
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? |
Right. But I think for the moment we can support basic completion which takes not much work but gives big experience enhancement. |
#133393 introduces keyword expansion, but what about name expansion (the part I was originally worried about)? |
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) |
@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. |
It's not on my list but sounds like a good candidate. See also #133247 that added syntax highlighting in the REPL and tools like https://github.com/dbcli/litecli. |
Opened #133447 :-) |
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. |
…LI (python#133393)" temporarily This reverts commit 62b3d2d, which broke buildbots
It looks that the |
Got an error message:
But it's totally OK, I think authorship is not a big thing. Hope the test failure is not hard to fix. |
Oh. GitHub is too secure... |
I think it will be more convenient for you to push commits if the PR is from you. Waiting for your PR :) |
Uh oh!
There was an error while loading. Please reload this page.
Feature 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
The text was updated successfully, but these errors were encountered: