Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tvandinther/libsql-client-dotnet
A .NET client for libsql
https://github.com/tvandinther/libsql-client-dotnet
database-client dotnet dotnet-standard library libsql turso
Last synced: 5 days ago
JSON representation
A .NET client for libsql
- Host: GitHub
- URL: https://github.com/tvandinther/libsql-client-dotnet
- Owner: tvandinther
- License: mit
- Created: 2023-09-27T09:12:37.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-10-14T13:32:10.000Z (25 days ago)
- Last Synced: 2024-11-02T09:05:43.997Z (6 days ago)
- Topics: database-client, dotnet, dotnet-standard, library, libsql, turso
- Language: C#
- Homepage: https://www.nuget.org/packages/Libsql.Client
- Size: 449 KB
- Stars: 59
- Watchers: 7
- Forks: 3
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-turso - libsql-client-dotnet
README
![tests](https://github.com/tvandinther/libsql-client-dotnet/actions/workflows/test.yaml/badge.svg)
# Libsql.Client
A .NET client library for libsql.
**This project is still in early development and not ready for production use.**
### Currently Supported Features
- Creating a database:
- In memory.
- From file.
- From connection string.
- Executing SQL statements:
- Non-parameterised.### Planned Features
- Positional and named arguments.
- Embedded replicas.
- Prepared statements.
- Batched statements.
- Transactions.## Usage
For an example, see the Demo project in the repository.
### Creating a Database
```csharp
// Create an in-memory database.
var dbClient = DatabaseClient.Create(opts => {
opts.Url = ":memory:";
});
```### Executing SQL Statements
Using direct queries
```csharp
await dbClient.Execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, height REAL)");
```Using positional arguments
```csharp
await dbClient.Execute("SELECT name FROM users WHERE id = ?", userId);
```### Querying the Database
```csharp
User ToUser(IEnumerable row)
{
var rowArray = row.ToArray();if (
rowArray[0] is Integer { Value: var id } &&
rowArray[1] is Text { Value: var name } &&
rowArray[2] is Real { Value: var height }
{
return new User(id, name, height);
}throw new ArgumentException();
}var result = await dbClient.Execute("SELECT * FROM users");
var users = result.Rows.Select(ToUser);
```### Closing the Database
```csharp
dbClient.Dispose();
```or with a `using` statement:
```csharp
using (var dbClient = DatabaseClient.Create(opts => {
opts.Url = ":memory:";
}))
{
// ...
}
```## Disclaimer
This project is still in early development and not ready for production use. The API is subject to include breaking changes on minor versions until version 1.0.
The full test suite is run only on a Linux x64 platform. Most of the test suite is run on Linux, Windows, and macOS x64 platforms. The test suite runs on .NET 7.
## Progress
- A database can be created:
- [x] In memory.
- [x] From file.
- [x] From connection string.
- [x] A database can be destroyed/closed/deallocated.
- [ ] An embedded replica can be created.
- [ ] An embeded replica can be synced.
- The database can execute SQL statements:
- [x] Non-parameterised.
- [x] Parameterised with positional arguments.
- [ ] Parameterised with named arguments.
- [ ] Prepared statements.
- [ ] Batched statements.
- [ ] Transactions.
- [x] A result set is returned from an execution.
- [x] With the column names.
- [x] With an enumerable of enumerable (rows) of typed boxed values.
- [x] With the number of affected rows.
- [x] With the last inserted row id.