Skip to content

Conversation

@fry69
Copy link

@fry69 fry69 commented Oct 10, 2025

fix #650

This code was generated with VS Code Copilot agent and Sonnet-4.5.

I think it did its job quite well.

Generated PR message below


Add SQLite URI filename support

Implements support for SQLite URI filenames across CLI and Python API (fixes #650).

Changes

sqlite_utils/db.py:

  • Modified Database.__init__() to detect URI filenames (strings starting with ) and pass uri=True parameter to sqlite3.connect()

sqlite_utils/cli.py:

  • Added DatabasePath class extending click.Path to handle URI filenames
  • URIs bypass file existence validation while maintaining normal validation for regular paths
  • Replaced all database path parameters throughout CLI with DatabasePath

tests/test_uri.py:

  • Added comprehensive test coverage for URI functionality
  • Tests include: read-only mode, immutable flag, multiple parameters, CLI commands, path validation

Documentation:

  • Added URI filenames section to CLI documentation
  • Added URI examples to Python API documentation

Usage

CLI:

sqlite-utils tables 'file:data.db?mode=ro&immutable=1'
sqlite-utils query 'file:data.db?mode=ro' "SELECT * FROM items"

Python API:

from sqlite_utils import Database
db = Database("file:data.db?mode=ro&immutable=1")

Testing

All existing tests pass. Added 13 new tests covering URI functionality. Type checking passes with mypy.


📚 Documentation preview 📚: https://sqlite-utils--670.org.readthedocs.build/en/670/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ability to pass a URI to the CLI tools

1 participant