SimpleFileDB 1.0.2

Package Description

Install-Package SimpleFileDB -Version 1.0.2
dotnet add package SimpleFileDB --version 1.0.2
<PackageReference Include="SimpleFileDB" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleFileDB --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SimpleFileDB, 1.0.2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install SimpleFileDB as a Cake Addin
#addin nuget:?package=SimpleFileDB&version=1.0.2

// Install SimpleFileDB as a Cake Tool
#tool nuget:?package=SimpleFileDB&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

SimpleFileDB

SimpleFileDB is a free, fast, multiplatform, lightweight .NET Standard database library.

Databases are split into tables (stored as folders). Tables are split into rows (stored as JSON files). Rows are split into columns (stored as first-level properties in a JSON file).

Usage

using System;
using System.IO;

namespace SimpleFileDB.Sample
{
    class MySampleRowClass
    {
        public int Aaa = 346;
        public string Bbb = "Sample text.";
        public float Ccc = 3.14159f;
    }

    class SampleProgram
    {
        static async void Main(string[] args)
        {
            string pathdb = Path.GetTempFileName();
            File.Delete(pathdb);
            Directory.CreateDirectory(pathdb);
            Console.WriteLine($"Sample database created in {pathdb}");

            string table1_name = "my table";
            string table1_row1_index = "first row";
            string table1_row2_index = "second row";

            SimpleFileDB db = new SimpleFileDB(pathdb);

            db.CreateTable(table1_name);
            db[table1_name][table1_row1_index] = "the content of the first row is simply a string"; // create/update a row
            string row_read_back = await db[table1_name].GetRow<string>(table1_row1_index); // read a row - note: support for asynchronous operations
            Console.WriteLine($"The value of the first row is: \"{row_read_back}\".");

            db[table1_name][table1_row2_index] = new MySampleRowClass(); // create/update a row containing an object
            MySampleRowClass readvalue = db[table1_name].GetRow<MySampleRowClass>(table1_row2_index).Result; // read a row as an object, synchronously
            Console.WriteLine($"The second row contains a {nameof(MySampleRowClass)} object: Aaa={readvalue.Aaa}, Bbb={readvalue.Bbb}, Ccc={readvalue.Ccc}.");
            Console.WriteLine($"The second row has been stored as a JSON file with contents:{Environment.NewLine}{File.ReadAllText(Path.Combine(pathdb, table1_name, table1_row2_index))}");

            db[table1_name].Delete(table1_row1_index);
            db[table1_name].Delete(table1_row2_index);
            db.DeleteTable(table1_name, deletecontents: false);
        }
    }
}

Features

  • Extremely easy to use.
  • Multiplatform (platform agnostic).
  • Each row is a simply JSON file. Therefore it can be easily stored on disk, network share, Google Drive, OneDrive...
  • Row contents can be any serializable object. The value of a row can be an integer, a float, a string, or your own class.
  • Read/write operations are asynchronous, so DB access does not necessarily block the rest of your application.

SimpleFileDB

SimpleFileDB is a free, fast, multiplatform, lightweight .NET Standard database library.

Databases are split into tables (stored as folders). Tables are split into rows (stored as JSON files). Rows are split into columns (stored as first-level properties in a JSON file).

Usage

using System;
using System.IO;

namespace SimpleFileDB.Sample
{
    class MySampleRowClass
    {
        public int Aaa = 346;
        public string Bbb = "Sample text.";
        public float Ccc = 3.14159f;
    }

    class SampleProgram
    {
        static async void Main(string[] args)
        {
            string pathdb = Path.GetTempFileName();
            File.Delete(pathdb);
            Directory.CreateDirectory(pathdb);
            Console.WriteLine($"Sample database created in {pathdb}");

            string table1_name = "my table";
            string table1_row1_index = "first row";
            string table1_row2_index = "second row";

            SimpleFileDB db = new SimpleFileDB(pathdb);

            db.CreateTable(table1_name);
            db[table1_name][table1_row1_index] = "the content of the first row is simply a string"; // create/update a row
            string row_read_back = await db[table1_name].GetRow<string>(table1_row1_index); // read a row - note: support for asynchronous operations
            Console.WriteLine($"The value of the first row is: \"{row_read_back}\".");

            db[table1_name][table1_row2_index] = new MySampleRowClass(); // create/update a row containing an object
            MySampleRowClass readvalue = db[table1_name].GetRow<MySampleRowClass>(table1_row2_index).Result; // read a row as an object, synchronously
            Console.WriteLine($"The second row contains a {nameof(MySampleRowClass)} object: Aaa={readvalue.Aaa}, Bbb={readvalue.Bbb}, Ccc={readvalue.Ccc}.");
            Console.WriteLine($"The second row has been stored as a JSON file with contents:{Environment.NewLine}{File.ReadAllText(Path.Combine(pathdb, table1_name, table1_row2_index))}");

            db[table1_name].Delete(table1_row1_index);
            db[table1_name].Delete(table1_row2_index);
            db.DeleteTable(table1_name, deletecontents: false);
        }
    }
}

Features

  • Extremely easy to use.
  • Multiplatform (platform agnostic).
  • Each row is a simply JSON file. Therefore it can be easily stored on disk, network share, Google Drive, OneDrive...
  • Row contents can be any serializable object. The value of a row can be an integer, a float, a string, or your own class.
  • Read/write operations are asynchronous, so DB access does not necessarily block the rest of your application.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.2 48 5/21/2021
1.0.1 71 4/29/2021
1.0.0 74 4/29/2021