Giter Club home page Giter Club logo

libsql-client-dotnet's Introduction

tests

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

// Create an in-memory database.
var dbClient = DatabaseClient.Create(opts => {
    opts.Url = ":memory:";
});

Executing SQL Statements

await dbClient.Execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, height REAL)");

Querying the Database

User ToUser(Value[] 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

dbClient.Dispose();

or with a using statement:

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:
    • In memory.
    • From file.
    • From connection string.
  • 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:
    • Non-parameterised.
    • Parameterised with positional arguments.
    • Parameterised with named arguments.
  • Prepared statements.
  • Batched statements.
  • Transactions.
  • A result set is returned from an execution.
    • With the column names.
    • With an enumerable of enumerable (rows) of typed boxed values.
    • With the number of affected rows.
    • With the last inserted row id.

libsql-client-dotnet's People

Contributors

tvandinther avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

libsql-client-dotnet's Issues

Does this work with macOS / Apple Silicon?

I clone the repo, generate the bindings, build the demo...which all seems to work, but when I run the demo I get:

Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'Demo, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

Similarly when I create a new project and add the Libsql.Client nuget package...the app builds fine but when run I get:

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Libsql.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

Any ideas?

Add support for osx-arm64 runtimes

First raised in #17, the FFI binaries are only built for x64 on Linux, Windows and MacOS. MacOS running on Apple silicon is common enough to require support.

Expected changes:

A new build step targetting a Github Actions runner using Apple silicon to build an additional FFI binary.

Github has recently released into beta their macos-14 runner which uses the M1 chip. A new build step can be created targetting this runner.
https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories

Copying the new osx-arm64 binary into the package

The csproj file will need to be changed to distinguish between and copy the x64 and arm64 binaries into their respective runtime directories. According to the MSBuild docs this should be runtimes/osx-arm64/native

Column names and string values are parsed incorrectly on Windows

Operating system: Windows 11
Version: 0.2.2

Actual:

??r??? ???, ??, ?????????l??????????????'??โ†‘??????, ??
------------------------
1, ??????, 182.6, [ a4 c7 b8 e2 ... 9a 09 3f ed ]
2, ????, 0.5, [ 00 ]

Expected:

id, name, height, data
------------------------
1, John Doe, 182.6, [ a4 c7 b8 e2 ... 9a 09 3f ed ]
2, Jane Doe, 0.5, [ 00 ]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.