Skip to content

hermogenes/libsql-http-client-dotnet

Repository files navigation

LibSql.Http.Client

An alternative libSQL .NET client, supporting HTTP protocol, fully trimmable and AOT compatible.

Warning

This is not an official libSQL client

Continuous Integration NuGet NuGet

About

This client is a .NET implementation of HRANA protocol, intented to communicate with libSQL server.

This lib is inspired by libsql-stateless-easy.

Requirements

  • .NET 8 (6 and 7 are supported as well)

Installation

Install Nuget package:

dotnet add package LibSql.Http.Client

Usage

The instance of the client expect an instance of HttpClient.

The most performant way is use a singleton instance of HttpClient.

Check the offical .NET HTTP client guidelines for more information.

var handler = new SocketsHttpHandler
{
    PooledConnectionLifetime = TimeSpan.FromMinutes(15) // Recreate every 15 minutes
};
var sharedClient = new HttpClient(handler);
var libSqlClient = new LibSqlHttpClient(sharedClient, new Uri("http://localhost:8080"));

Features

  • ✅ Single and batch commands
  • ✅ Transactions (*)
  • ✅ Positional args
  • ✅ Named args via Dictionary
  • ✅ Micro ORM like queries and results with minimum overhead
  • ❌ Interactive transactions not supported (transactions are done in a single request)

* Transactions are possible per statement(s) only. So distributed transaction is not possible (yet)!

Demo App

 dotnet run --project src/LibSql.Http.Client.DemoConsoleApp/LibSql.Http.Client.DemoConsoleApp.csproj

Check the code.