-
Notifications
You must be signed in to change notification settings - Fork 85
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
add dot command for views #217
Conversation
@amjith It occurs to me - if the premise of this PR is accepted - there's likely some doc changes that need to be made. Happy to chip in there as well, just lemme know. |
Could you add a test for this? Here's a good candidate test you can use as reference. |
BTW, I like the PR I do plan on merging this once I get a chance to try it out locally. |
Sounds good on both counts! Will do it over the weekend if that works. |
I tried the branch in my local db and works as expected. Here is the output uv run litecli /Users/kracekumar/Downloads/github.db
LiteCli: 0.1.dev429+g5be771e (SQLite: 3.47.1)
GitHub: https://github.com/dbcli/litecli
/Users/kracekumar/Downloads/github.db> .views
+-----------------+
| name |
+-----------------+
| dependent_repos |
| recent_releases |
| repos_starred |
+-----------------+
Time: 0.010s
/Users/kracekumar/Downloads/github.db> \dv
+-----------------+
| name |
+-----------------+
| dependent_repos |
| recent_releases |
| repos_starred |
+-----------------+
Time: 0.005s
/Users/kracekumar/Downloads/github.db> SELECT name
FROM sqlite_schema
WHERE type = 'view';
+-----------------+
| name |
+-----------------+
| dependent_repos |
| recent_releases |
| repos_starred |
+-----------------+
3 rows in set
Time: 0.004s
/Users/kracekumar/Downloads/github.db> SELECT name
FROM sqlite_master
WHERE type = 'view';
+-----------------+
| name |
+-----------------+
| dependent_repos |
| recent_releases |
| repos_starred |
+-----------------+
3 rows in set
Time: 0.004s
/Users/kracekumar/Downloads/github.db> .views repos_starred
+---------------+
| name |
+---------------+
| repos_starred |
+---------------+
Time: 0.006s
/Users/kracekumar/Downloads/github.db>
[F3] Multiline: OFF Database Source: https://github-to-sqlite.dogsheep.net/github |
args = tuple() | ||
query = """ | ||
SELECT name FROM sqlite_master | ||
WHERE type = 'view' AND name NOT LIKE 'sqlite_%' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason to ignore views with prefix sqlite_? Do you happen to know when these(sqlite_xxx) views are created?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this query is a modified version of the tables_query in sqlexecute.py. SQLite will create temporary tables for query planning purposes such as sqlite_stat*
. I don't think it is applicable to views.
Merging this now. I can add tests for it. |
Description
I use the
.tables
command a lot and occurred to me it might be useful to have one for views as well. I'd use it at least!Checklist
CHANGELOG.md
file.