Skip to content

fix: bind attach database path#748

Open
Gares95 wants to merge 1 commit into
simonw:mainfrom
Gares95:fix-attach-path-quote
Open

fix: bind attach database path#748
Gares95 wants to merge 1 commit into
simonw:mainfrom
Gares95:fix-attach-path-quote

Conversation

@Gares95
Copy link
Copy Markdown

@Gares95 Gares95 commented May 25, 2026

Summary

This updates Database.attach() to bind the attached database filepath as a SQL parameter instead of interpolating it into the ATTACH DATABASE statement.

What changed

  • Bind the resolved filepath with ATTACH DATABASE ? AS ...
  • Keep existing alias quoting behavior unchanged
  • Add Python API coverage for attached database paths containing an apostrophe
  • Add CLI --attach coverage for attached database paths containing an apostrophe

Why

Filepaths can contain apostrophes, and binding the path keeps attach() working for those valid paths without changing alias handling.

Tests

Focused Docker validation:

python -m pytest tests/test_attach.py tests/test_cli.py::test_attach tests/test_cli.py::test_attach_filepath_with_apostrophe -q

Result:

4 passed

Compatibility notes

This keeps path resolution and alias quoting behavior unchanged. The SQL text now uses a bound parameter for the filepath, which is consistent with parameterized SQLite execution.


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

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.

1 participant