SimpleTextDatabase 1.10.2
dotnet add package SimpleTextDatabase --version 1.10.2
NuGet\Install-Package SimpleTextDatabase -Version 1.10.2
<PackageReference Include="SimpleTextDatabase" Version="1.10.2" />
<PackageVersion Include="SimpleTextDatabase" Version="1.10.2" />
<PackageReference Include="SimpleTextDatabase" />
paket add SimpleTextDatabase --version 1.10.2
#r "nuget: SimpleTextDatabase, 1.10.2"
#:package SimpleTextDatabase@1.10.2
#addin nuget:?package=SimpleTextDatabase&version=1.10.2
#tool nuget:?package=SimpleTextDatabase&version=1.10.2
SimpleTextDatabase
A simple text-based database with basic ORM functionality for .NET 8 / 9 / 10. One file on disk, tables and rows are line-based, with sync and async APIs, transactions, and DI integration.
Install
dotnet add package SimpleTextDatabase
Quick start
using WordDataBase;
using var db = new TextDatabase("data.txt");
db.CreateTable("users", new[]
{
new Column("Id", DataType.Int),
new Column("Name", DataType.String),
new Column("Active", DataType.Bool),
});
db.InsertData("users", new[] { "1", "Alice", "true" });
db.InsertData("users", new[] { "2", "Bob", "false" });
var rows = db.Select("users",
columns: new[] { "Name" },
filter: r => r[0] != "Bob",
orderByColumn: "Name");
// => [ ["Alice"] ]
Async API
Every operation has an async sibling that uses File.ReadAllLinesAsync / WriteAllLinesAsync:
await db.CreateTableAsync("users", schema, cancellationToken);
await db.InsertDataAsync("users", row, cancellationToken);
var rows = await db.SelectAsync("users", cancellationToken: cancellationToken);
Sync and async paths share a single SemaphoreSlim gate, so mixing them is safe.
Dependency injection
using Microsoft.Extensions.DependencyInjection;
using WordDataBase;
var services = new ServiceCollection();
services.AddSimpleTextDatabase(opts => opts.FilePath = "data.txt");
// or
services.AddSimpleTextDatabase("data.txt");
using var sp = services.BuildServiceProvider();
var db = sp.GetRequiredService<IDatabase>();
IDatabase is registered as a singleton.
Transactions
db.BeginTransaction();
try
{
db.InsertData("users", new[] { "3", "Carol", "true" });
db.CommitTransaction();
}
catch
{
db.RollbackTransaction();
throw;
}
- Only one transaction is active at a time.
CommitandRollbackclean up the temp file infinally, so a crash mid-commit doesn't leak it permanently.DropDatabaseaborts any active transaction and recreates an empty file.
Supported column types
DataType |
Stored as |
|---|---|
Int |
invariant decimal int |
String |
UTF-8 text |
Bool |
invariant true/false |
Values are parsed and re-serialized with CultureInfo.InvariantCulture so files round-trip across locales.
Build & test
dotnet build WordDataBase.sln
dotnet test WordDataBase.sln
Release
Bump <Version> in src/WordDataBase/WordDataBase.csproj, commit, push to product. CI builds, packs, and publishes to nuget.org automatically (--skip-duplicate).
License
MIT — see LICENSE.txt.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
v1.10.2: CI/CD triggers on `product` branch instead of `main`.
v1.10.1: Updated package icon; gitignore Claude Code artifacts.
v1.10.0: Major refactor. Added net10.0 target, async API, DI extensions, fixed transaction bugs, unified namespace, restructured into src/ layout. See CHANGELOG.md.