Skip to content

Add SQLite database preview support to Peek#45846

Open
thomastv wants to merge 1 commit intomicrosoft:mainfrom
thomastv:feature/sqlite-db-previewer
Open

Add SQLite database preview support to Peek#45846
thomastv wants to merge 1 commit intomicrosoft:mainfrom
thomastv:feature/sqlite-db-previewer

Conversation

@thomastv
Copy link

Summary of the Pull Request

This PR adds SQLite database file preview support to the Peek utility, resolving issue #45757 . Three new model classes (SQLiteTableInfo, SQLiteColumnInfo, ISQLitePreviewer) and a core SQLitePreviewer class were added to read .db, .sqlite, and .sqlite3 files read-only using Microsoft.Data.Sqlite, fetching table schema via PRAGMA table_info and up to 200 rows per table. A new SQLiteControl XAML control presents the data in a two-pane layout — a tree view listing all tables on the left and a data grid showing columns and rows on the right, with intelligent column sizing that stretches the last column when space allows and falls back to horizontal scrolling for wide tables. The previewer was wired into the existing previewerFactory and FilePreview host, and three localizable strings were added to Resources.resw.

PR Checklist

  • Communication: I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected
  • Tests: Added/updated and all pass
  • Localization: All end-user-facing strings can be localized
  • Dev docs: Added/updated
  • New binaries: Added on the required places
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

  • Added the new SQLiteControl user control (SQLiteControl.xaml and SQLiteControl.xaml.cs) for visualizing SQLite database tables, columns, and data in a split-pane UI with a DataGrid and tree view.
  • Implemented supporting model classes: SQLiteTableInfo for table metadata and rows, and SQLiteColumnInfo for column details and display formatting.
  • Defined the ISQLitePreviewer interface for previewer implementations that expose SQLite table data and metadata.
  • Added the SQLitePreviewer to the previewer factory logic, enabling automatic detection and previewing of SQLite files.

Validation Steps Performed

  1. Verified that the new feature works locally
  2. Verified that the existing features are also working correctly after adding new changes
  3. Created a dummy .db file and verified that the default fallback screen appears, since it isn't a valid sqlite file
image


public IArchivePreviewer? ArchivePreviewer => Previewer as IArchivePreviewer;

public ISQLitePreviewer? SQLitePreviewer => Previewer as ISQLitePreviewer;

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

ISQ is not a recognized word. (unrecognized-spelling)

public IArchivePreviewer? ArchivePreviewer => Previewer as IArchivePreviewer;

public ISQLitePreviewer? SQLitePreviewer => Previewer as ISQLitePreviewer;

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

ISQ is not a recognized word. (unrecognized-spelling)
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation

Check failure

Code scanning / check-spelling

Check File Path Error

ISQ is not a recognized word. (check-file-path)

namespace Peek.FilePreviewer.Previewers.Interfaces
{
public interface ISQLitePreviewer : IPreviewer, IPreviewTarget, IDisposable

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

ISQ is not a recognized word. (unrecognized-spelling)

namespace Peek.FilePreviewer.Previewers.SQLitePreviewer
{
public partial class SQLitePreviewer : ObservableObject, ISQLitePreviewer

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

ISQ is not a recognized word. (unrecognized-spelling)
@github-actions
Copy link

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

Unrecognized words (1)

ISQ

To accept these unrecognized words as correct, you could run the following commands

... in a clone of the git@github.com:thomastv/PowerToys.git repository
on the feature/sqlite-db-previewer branch (ℹ️ how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/c635c2f3f714eec2fcf27b643a1919b9a811ef2e/apply.pl' |
perl - 'https://github.com/microsoft/PowerToys/actions/runs/22515739657/attempts/1' &&
git commit -m 'Update check-spelling metadata'
Errors and Warnings ❌ (2)

See the 📂 files view, the 📜action log, or 📝 job summary for details.

❌ Errors and Warnings Count
❌ check-file-path 1
⚠️ ignored-expect-variant 3

See ❌ Event descriptions for more information.

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

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.

Feature Request: Add SQLite (.db) File Preview Support to Peek

1 participant