A Terminal User Interface (TUI) tool for executing SQL queries and generating 100% offline HTML reports.
____ _ ____
| _ \| |__ | _ \ _ _ _ __ ___ _ __ ___ _ __
| | | | '_ \| | | | | | | '_ ` _ \| '_ \ / _ \ '__|
| |_| | |_) | |_| | |_| | | | | | | |_) | __/ |
|____/|_.__/|____/ \__,_|_| |_| |_| .__/ \___|_|
|_|
- 🗄️ Multi-provider — SQLite & PostgreSQL out of the box (easily extensible)
- 🎨 Beautiful TUI — powered by Spectre.Console
- 📊 Rich HTML reports — dark-themed, sortable, filterable, paginated, 100% self-contained (no CDN)
- 💉 Dependency Injection —
Microsoft.Extensions.DependencyInjection - 🏗️ Strategy pattern — add new providers by implementing
IDbProvider - ⚡ Dapper — lightweight, fast query execution
DbDumper/
├── Program.cs # Composition root (DI setup)
├── src/
│ ├── Core/
│ │ ├── Interfaces/
│ │ │ ├── IDbProvider.cs # Strategy interface
│ │ │ ├── IQueryService.cs # Orchestration interface
│ │ │ └── IReportGenerator.cs # Report strategy interface
│ │ └── Models/
│ │ ├── QueryResult.cs # Rich result with metadata
│ │ └── ConnectionProfile.cs # Config model + DbDumperOptions
│ ├── Providers/
│ │ ├── DbProviderBase.cs # Abstract base (Dapper logic)
│ │ ├── SqliteProvider.cs # SQLite implementation
│ │ └── PostgresProvider.cs # PostgreSQL implementation
│ ├── Services/
│ │ └── QueryService.cs # Provider resolution + execution
│ ├── Reports/
│ │ └── HtmlReportGenerator.cs # Fully self-contained HTML reports
│ ├── TUI/
│ │ └── DbDumperApp.cs # Spectre.Console TUI loop
│ └── ServiceCollectionExtensions.cs # DI registration
└── config/
└── appsettings.json # Connections & settings
| Pattern | Where |
|---|---|
| Strategy | IDbProvider — each DB engine is a swappable strategy |
| Strategy | IReportGenerator — swappable report format |
| Factory / Registry | QueryService resolves the correct IDbProvider at runtime |
| Options | DbDumperOptions bound via IOptions<T> |
| DI / IoC | Full Microsoft.Extensions.DependencyInjection wiring |
cd DbDumper
dotnet runEdit config/appsettings.json:
{
"DbDumper": {
"ReportsOutputPath": "./reports",
"QueryTimeoutSeconds": 30,
"Connections": [
{
"Alias": "local-sqlite",
"Provider": "sqlite",
"ConnectionString": "Data Source=./data/sample.db"
},
{
"Alias": "my-postgres",
"Provider": "postgres",
"ConnectionString": "Host=localhost;Database=mydb;Username=user;Password=pass"
}
]
}
}You can also override any setting with environment variables prefixed with DBDUMPER_:
DBDUMPER_DbDumper__QueryTimeoutSeconds=60 dotnet run- Create
src/Providers/MySqlProvider.csimplementingDbProviderBase:
public sealed class MySqlProvider : DbProviderBase
{
public override string ProviderName => "MySQL";
public override string ProviderKey => "mysql";
public override async Task<IDbConnection> OpenConnectionAsync(
string connectionString, CancellationToken cancellationToken = default)
{
var conn = new MySqlConnection(connectionString);
await conn.OpenAsync(cancellationToken);
return conn;
}
}- Register it in
ServiceCollectionExtensions.cs:
services.AddSingleton<IDbProvider, MySqlProvider>();- Add a connection entry in
appsettings.jsonwith"Provider": "mysql".
Generated reports are 100% self-contained — no internet connection required:
- 🌑 Dark theme with syntax-aware column rendering
- 🔍 Client-side row filtering (instant, no server)
↕️ Sortable columns (click header, supports numeric sort)- 📄 Client-side pagination (100 rows/page)
- 📋 Query metadata: provider, alias, elapsed time, row/column counts
- 💾 The full SQL query is embedded in the report
public sealed class QueryResult
{
public required string Query { get; init; }
public required string ProviderName { get; init; }
public required string ConnectionAlias { get; init; }
public required List<string> Columns { get; init; }
public required IEnumerable<dynamic> Rows { get; init; }
public int RowCount { get; init; }
public required DateTimeOffset ExecutedAt { get; init; }
public required TimeSpan Elapsed { get; init; }
public bool IsSuccess { get; init; }
public string? ErrorMessage { get; init; }
public string? ReportTitle { get; set; }
}