Add support for URI style database names#234
Merged
amjith merged 4 commits intodbcli:mainfrom Aug 25, 2025
Merged
Conversation
SQLite accepts URI style db names: * https://docs.python.org/3/library/sqlite3.html#sqlite3-uri-tricks * https://www.sqlite.org/c3ref/open.html#urifilenameexamples This is particularly useful for opening databases in read-only mode (also with multiple connections, when using `cache=shared`). Although, this might be a corner case for `litecli` it'll help my use-case of embedding litecli in a personal app.
amjith
requested changes
Aug 23, 2025
litecli/sqlexecute.py
Outdated
| if db.startswith("file:"): | ||
| uri = True | ||
| db_name = db | ||
| db_filename, *_ = db_name[5:].split("?", 1) |
Member
There was a problem hiding this comment.
This looks a little brittle. How about using the urlparse() from the urllib.parse module?
We can do
parsed = urlparse(db)
db_filename = parsed.path
Contributor
Author
There was a problem hiding this comment.
@amjith Thanks for your time!
Sure yeah. tbh, I just wanted to keep the change minimal and stay consistent with the use of string functions elsewhere in the code. I've updated the code. Is this what you had in mind ?
This is a small enough change and I'm happy for you to adapt it in whatever way you think seems best.
amjith
approved these changes
Aug 25, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
SQLite accepts URI style db names:
This is particularly useful for opening databases in read-only mode (also with multiple connections, when using
cache=shared). Although, this might be a corner case forlitecliit'll help my use-case of embedding litecli in a personal app.Checklist
CHANGELOG.mdfile.