{"id":15824459,"url":"https://github.com/sjefvanleeuwen/rqlite-dotnet","last_synced_at":"2025-05-12T20:54:29.487Z","repository":{"id":115780654,"uuid":"274769520","full_name":"sjefvanleeuwen/rqlite-dotnet","owner":"sjefvanleeuwen","description":"A lightweight database HTTP API client for rqlite. rqlite is a lightweight, distributed relational database, which uses RAFT and SQLite as its storage engine. ","archived":false,"fork":false,"pushed_at":"2024-07-09T21:24:05.000Z","size":84,"stargazers_count":5,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-06T08:41:57.433Z","etag":null,"topics":["cluster","data","database","distributed","distributed-computing","distributed-database","distributed-systems","dotnet","raft","rqlite"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sjefvanleeuwen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-24T21:06:24.000Z","updated_at":"2023-08-12T17:11:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"7657f09f-a484-4551-84ac-f52466f0dfc7","html_url":"https://github.com/sjefvanleeuwen/rqlite-dotnet","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjefvanleeuwen%2Frqlite-dotnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjefvanleeuwen%2Frqlite-dotnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjefvanleeuwen%2Frqlite-dotnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sjefvanleeuwen%2Frqlite-dotnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sjefvanleeuwen","download_url":"https://codeload.github.com/sjefvanleeuwen/rqlite-dotnet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253822390,"owners_count":21969830,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cluster","data","database","distributed","distributed-computing","distributed-database","distributed-systems","dotnet","raft","rqlite"],"created_at":"2024-10-05T08:42:14.848Z","updated_at":"2025-05-12T20:54:29.445Z","avatar_url":"https://github.com/sjefvanleeuwen.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"![rqlite-dotnet](doc/img/rqlite-dotnet.svg)\n\n[![nuget](https://img.shields.io/nuget/v/RqLite.Client)](https://www.nuget.org/packages/RqLite.Client/)\n![.NET Core](https://github.com/sjefvanleeuwen/rqlite-dotnet/workflows/.NET%20Core/badge.svg)\n\n# What is it?\n\nA lightweight database dot net HTTP API client for rqlite. rqlite is a lightweight, distributed relational database, which uses SQLite as its storage engine. Forming a cluster is very straightforward, it gracefully handles leader elections, and tolerates failures of machines, including the leader. rqlite is available for Linux, OSX, and Microsoft Windows.\n\nrqlite uses Raft to achieve consensus across all the instances of the SQLite databases, ensuring that every change made to the system is made to a quorum of SQLite databases, or none at all.\n\nFor more information visit the project\n\n[![Circle CI](https://circleci.com/gh/rqlite/rqlite/tree/master.svg?style=svg)](https://circleci.com/gh/rqlite/rqlite/tree/master) [![appveyor](https://ci.appveyor.com/api/projects/status/github/rqlite/rqlite?branch=master\u0026svg=true)](https://ci.appveyor.com/project/otoolep/rqlite) [![GoDoc](https://godoc.org/github.com/rqlite/rqlite?status.svg)](https://godoc.org/github.com/rqlite/rqlite) [![Go Report Card](https://goreportcard.com/badge/github.com/rqlite/rqlite)](https://goreportcard.com/report/github.com/rqlite/rqlite) [![Release](https://img.shields.io/github/release/rqlite/rqlite.svg)](https://github.com/rqlite/rqlite/releases) [![Docker](https://img.shields.io/docker/pulls/rqlite/rqlite?style=plastic)](https://hub.docker.com/r/rqlite/rqlite/) [![Google Group](https://img.shields.io/badge/Google%20Group--blue.svg)](https://groups.google.com/group/rqlite)\n\nhttps://github.com/rqlite/rqlite\n\n# Quick Start\n\n## Install NuGet\n\n```\ndotnet add package RqLite.Client --version 0.0.2-alpha\n```\n\nor visit the nuget for other options on: https://www.nuget.org/packages/RqLite.Client/\n\n\n## Initialize a client\n\nYou can initialize the client with a single uri (single node operation), or if running a cluster you can provide multiple endpoints as illustrated below. The client will automatically look for the RAFT leader node.\n\n```csharp\n var client = new RqLiteClient(\"http://localhost:4001,http://localhost:4002,http://localhost:4003\");\n```\n\n## Perform an Execution\n\nExecutions can be used to execute sql statements such as \"INSERT, \"DROP TABLE foo\" and \"CREATE TABLE foo\":\n\n```csharp\nvar createTable = client.Execute(\"CREATE TABLE foo (id integer not null primary key, name text)\");\nvar createFiona = await client.ExecuteAsync(\"INSERT INTO foo(name) VALUES(\\\"fiona\\\")\");\n```\n\n## Perform a query\n\nQueries are used for sql statements such as the \"SELECT\" query. You can either use sync or async calls:\n\n```csharp\nvar readFiona = client.Query(\"SELECT * FROM FOO WHERE name=\\\"fiona\\\"\");\nvar readFiona = await client.QueryAsync(\"SELECT * FROM FOO WHERE name=\\\"fiona\\\"\");\n```\n\n## Setting multiple flags\n\nrqlite provides three flags. \n\n* Flag for timings,showing execution time in the json query result\n* Flag for pretty print, return pretty print json in the query result\n* Flag for transaction, execution of multiple sql statements in one execution (as shown above)\n\nThese can be passed by the `RqLiteFlags` enum as a mask. To Enable all flags:\n\n```csharp\nRqLiteFlags maskAll =  (RqLiteFlags.Pretty | RqLiteFlags.Timings | RqLiteFlags.Transaction);\n```\n\nThen pass the mask into the Query or Execution path.\n\n## Perform a transaction\n\nYou can perform multiple sql statements in one transaction. Please use the flag option:\n\n```csharp\nRqLiteFlags maskTransaction = RqLiteFlags.Transaction;\nvar transaction = await client.ExecuteAsync(new string[] {\n    \"INSERT INTO foo(name) VALUES(\\\"gary\\\")\",\n    \"INSERT INTO foo(name) VALUES(\\\"fred\\\")\"\n}, maskTransaction);\n```\n\n### Parameterized Execute (since 0.0.2-alpha)\n\n```csharp\nvar parameters = new object[] { \"fiona\", 20 };\nvar createFiona = await client.ExecuteAsync(\"INSERT INTO foo(name,age) VALUES(?,?)\", parameters);\n```\n\n### Parameterized Query\n```csharp\nvar parameters = new object[] { \"fiona\", 20 };\nvar readFiona = await client.QueryAsync(\"SELECT * FROM foo WHERE name=?\", parameters[0] );\n```\n\n## Integration Tests\n\n### Single rqlite Node\n\nThe project contains a couple of simple integration tests. To test, it suffices to start up a single node rqlite docker container.\n\n```\ndocker run --name rqlite -p 4001:4001 -p4002:4002 rqlite/rqlite\n```\n\nThis will spin up rqlite, with an in memory database with the service listening on port 4001. The raft will automatically\nbe upgraded to leader (from Follow state) on port 4002. This will be sufficient to do some easy integration tests.\n\n```\n            _ _ _\n           | (_) |\n  _ __ __ _| |_| |_ ___\n | '__/ _  | | | __/ _ \\   The lightweight, distributed\n | | | (_| | | | ||  __/   relational database.\n |_|  \\__, |_|_|\\__\\___|\n         | |               www.rqlite.com\n         |_|\n\n[rqlited] 2021/01/29 23:29:02 rqlited starting, version v5.9.0, commit e9332ded2f4d9fa232cde2c670b876dcc53a5133, branch master\n[rqlited] 2021/01/29 23:29:02 go1.14, target architecture is amd64, operating system target is linux\n[rqlited] 2021/01/29 23:29:02 no preexisting node state detected in /rqlite/file/data, node may be bootstrapping\n[rqlited] 2021/01/29 23:29:02 no join addresses set\n[store] 2021/01/29 23:29:02 opening store with node ID 0.0.0.0:4002\n[store] 2021/01/29 23:29:02 ensuring directory at /rqlite/file/data exists\n[store] 2021/01/29 23:29:02 SQLite in-memory database opened\n2021-01-29T23:29:02.591Z [INFO]  raft: initial configuration: index=0 servers=[]\n[store] 2021/01/29 23:29:02 executing new cluster bootstrap\n2021-01-29T23:29:02.592Z [INFO]  raft: entering follower state: follower=\"Node at [::]:4002 [Follower]\" leader=\n2021-01-29T23:29:04.499Z [WARN]  raft: heartbeat timeout reached, starting election: last-leader=\n2021-01-29T23:29:04.499Z [INFO]  raft: entering candidate state: node=\"Node at [::]:4002 [Candidate]\" term=2\n2021-01-29T23:29:04.510Z [INFO]  raft: election won: tally=1\n2021-01-29T23:29:04.510Z [INFO]  raft: entering leader state: leader=\"Node at [::]:4002 [Leader]\"\n[store] 2021/01/29 23:29:04 waiting for up to 2m0s for application of initial logs\n[http] 2021/01/29 23:29:04 service listening on [::]:4001\n[rqlited] 2021/01/29 23:29:04 node is ready\n\n```\n\n### rqlite 3 node cluster\n\nThe integration tests has a constant called: `CLUSTERTEST` defined in the RqLite.Client.Tests.cpsoj\n\n```XML\n  \u003cPropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|AnyCPU'\"\u003e\n    \u003cDefineConstants\u003eTRACE;DEBUG;CLUSTERTEST\u003c/DefineConstants\u003e\n  \u003c/PropertyGroup\u003e\n```\n\nThis allows you to write mixed tests, for either single or multi node tests. Consider the following\nintegration test as an example:\n\n```csharp\n        [Fact]\n        [Trait(\"Category\", \"Integration\")]\n        public async void CanConnectToCluster()\n        {\n            var target = new RqliteRaftClient(connectionString);\n            var nodes = await target.ConnectAsync();\n#if CLUSTERTEST\n            Assert.Equal(3, nodes.Count());\n#else\n            Assert.Equal(1, nodes.Count());\n#endif\n        }\n```\n\nTo spin up a the 3 node cluster (without docker) with correct ports as used by the integration tests:\n\n```\n$ rqlited -node-id 1 -http-addr localhost:4001 -raft-addr localhost:4002 ./node1\n$ rqlited -node-id 2 -http-addr localhost:4003 -raft-addr localhost:4004 -join http://localhost:4001 ./node2\n$ rqlited -node-id 3 -http-addr localhost:4005 -raft-addr localhost:4006 -join http://localhost:4001 ./node3\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsjefvanleeuwen%2Frqlite-dotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsjefvanleeuwen%2Frqlite-dotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsjefvanleeuwen%2Frqlite-dotnet/lists"}