Rqlite 1.0.0-beta.23092301
This is a prerelease version of Rqlite.
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Rqlite --version 1.0.0-beta.23092301
NuGet\Install-Package Rqlite -Version 1.0.0-beta.23092301
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Rqlite" Version="1.0.0-beta.23092301" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Rqlite --version 1.0.0-beta.23092301
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Rqlite, 1.0.0-beta.23092301"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Rqlite as a Cake Addin #addin nuget:?package=Rqlite&version=1.0.0-beta.23092301&prerelease // Install Rqlite as a Cake Tool #tool nuget:?package=Rqlite&version=1.0.0-beta.23092301&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Rqlite .NET Client
Simple .NET client for Rqlite, with deserialisation support.
Features
- Configure multiple connections in settings
- Execute (e.g. INSERT) and Query support
- Return query results as rows or map to objects
- Use parameters for Execute and Query
- Support for transactions and multiple statements
Getting Started
The simplest way to start testing is to use Docker:
docker run -p4001:4001 rqlite/rqlite
Install the NuGet package. You can see a functioning example of the code below in the ReadmeApp project of this repository.
// register Rqlite with dependency injection
var (app, log) = Jeebs.Apps.Host.Create(args, (ctx, services) => services.AddRqlite());
// get IRqliteClientFactory instance
var factory = app.Services.GetRequiredService<IRqliteClientFactory>();
// create default IRqliteClient, listening on http://localhost:4001
using var client = factory.CreateClient();
// create a table
await client.ExecuteAsync("DROP TABLE IF EXISTS foo");
await client.ExecuteAsync("CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name TEXT, age INTEGER)");
// 0: insert a row using parameters
var sql0 = "INSERT INTO foo(name, age) VALUES(:name, :age)";
var param0 = new { name = "Fred", age = 42 };
var query0 = await client.ExecuteAsync(sql0, param0);
query0.Audit(
err: e => log.Err(e.Message),
ok: x => Console.WriteLine("Inserted record {0}.", x.Select(r => r.LastInsertId).First())
);
// Output: 'Inserted record 1.'
// 1: query the database using parameters
var sql1 = "SELECT * FROM foo WHERE name = :name";
var param1 = new { name = "Fred" };
var query1 = await client.QueryAsync<Person>(sql1, param1);
query1.Audit(
err: e => log.Err(e.Message),
ok: x => Console.WriteLine("{0} is {1}.", x.First().Name, x.First().Age)
);
// Output: 'Fred is 42.'
// 2: get value as a simple type
var sql2 = "SELECT age FROM foo WHERE name = :name";
var query2 = await client.GetScalarAsync<int>(sql2, param1);
query2.Audit(
err: e => log.Err(e.Message),
ok: x => Console.WriteLine("Fred is {0}.", x)
);
// Output: 'Fred is 42.'
// 3: map results to a complex type
var query3 = await client.QueryAsync<Person>(sql1, param1);
query3.Audit(
err: e => log.Err(e.Message),
ok: x => Console.WriteLine("Found {0}.", x.First())
);
// Output: 'Found Person { Id = 1, Name = Fred, Age = 42 }.'
// 4: insert multiple rows at once using tuples
var param2 = new { name = "Bella", age = 31 };
var param3 = new { name = "Alex", age = 59 };
var query4 = await client.ExecuteAsync(
(sql0, param2),
(sql0, param3)
);
query4.Audit(
err: e => log.Err(e.Message),
ok: x => Console.WriteLine("Inserted records {0}.", string.Join(", ", x.Select(r => r.LastInsertId)))
);
// Output: 'Inserted records 2, 3.'
internal sealed record Person(int Id, string Name, int Age);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- Microsoft.Extensions.Configuration.Abstractions (>= 7.0.0)
- Microsoft.Extensions.Http (>= 7.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 7.0.0)
- Wrap (>= 1.0.0-beta.23092301)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0-beta.24111501 | 44 | 11/15/2024 |
1.0.0-beta.24101801 | 74 | 10/18/2024 |
1.0.0-beta.24073001 | 55 | 7/30/2024 |
1.0.0-beta.24060601 | 111 | 6/6/2024 |
1.0.0-beta.24042401 | 74 | 4/24/2024 |
1.0.0-beta.24040501 | 71 | 4/6/2024 |
1.0.0-beta.24032302 | 60 | 3/23/2024 |
1.0.0-beta.23092301 | 87 | 9/23/2023 |
1.0.0-beta.23071402 | 95 | 7/14/2023 |
1.0.0-beta.23071401 | 89 | 7/14/2023 |
1.0.0-beta.23070801 | 94 | 7/8/2023 |