CsSqlite.Native
1.0.0
See the version list below for details.
dotnet add package CsSqlite.Native --version 1.0.0
NuGet\Install-Package CsSqlite.Native -Version 1.0.0
<PackageReference Include="CsSqlite.Native" Version="1.0.0" />
<PackageVersion Include="CsSqlite.Native" Version="1.0.0" />
<PackageReference Include="CsSqlite.Native" />
paket add CsSqlite.Native --version 1.0.0
#r "nuget: CsSqlite.Native, 1.0.0"
#:package CsSqlite.Native@1.0.0
#addin nuget:?package=CsSqlite.Native&version=1.0.0
#tool nuget:?package=CsSqlite.Native&version=1.0.0
CsSqlite
Extremely fast, robust, and lightweight SQLite bindings for .NET and Unity
English | 日本語
CsSqliteis a highly performant and lightweight SQLite binding built in C#. It provides an API equivalent to Microsoft.Data.Sqlite (the foundation package for EFCore SQLite) while achieving high performance through carefully tuned implementations.
Features
- Easy-to-use API
- High-performance implementation leveraging
Span<T>andUnsafe - Zero allocation, no additional memory allocation
- No dependencies
- Robust binding generation using Cysharp/csbindgen
- Supports Unity (Mono, IL2CPP)
Installation
NuGet packages
CsSqlite requires .NET Standard 2.1 or later. The package is available on NuGet.
.NET CLI
dotnet add package CsSqlite
Package Manager
Install-Package CsSqlite
Unity
For Unity, installation is possible via the Package Manager.
- Open the Package Manager from Window > Package Manager
- Click the "+" button > Add package from git URL
- Enter the following URL:
https://github.com/nuskey8/CsSqlite.git?path=src/CsSqlite.Unity/Assets/CsSqlite.Unity
Alternatively, open Packages/manifest.json and add the following to the dependencies block:
{
"dependencies": {
"com.nuskey.sqlite3.unity": "https://github.com/nuskey8/CsSqlite.git?path=src/CsSqlite.Unity/Assets/CsSqlite.Unity"
}
}
Additionally, you need to add the DLL of the dependency System.Runtime.CompilerServices.Unsafe to your project. Use NugetForUnity or rename the .nupkg downloaded from NuGet to .zip, extract it, and add the DLL from the extracted folder to your Unity project.
CsSqlite.Unity supports the following platforms:
| Platform | Architecture | Supported | Notes |
|---|---|---|---|
| Windows | x64 | ✅ | |
| x86 | ✅ | ||
| arm64 | ✅ | ||
| macOS | x64 | ✅ | |
| arm64 (Apple Silicon) | ✅ | ||
| Universal (x64 + arm64) | ✅ | ||
| Linux | x64 | ✅ (untested) | |
| arm64 | ✅ (untested) | ||
| iOS | arm64 | ✅ | |
| x64 | ✅ | ||
| Android | arm64 | ✅ |
Quick Start
using CsSqlite;
// Open a SqliteConnection
using var connection = new SqliteConnection("example.db");
connection.Open();
// Execute SQL
connection.ExecuteNonQuery("""
CREATE TABLE IF NOT EXISTS user (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
age INTEGER NOT NULL,
name TEXT NOT NULL
);
""");
// Overload accepting UTF-8 text
connection.ExecuteNonQuery("""
INSERT INTO user (id, name, age)
VALUES (1, 'Alice', 18),
(2, 'Bob', 32),
(3, 'Charlie', 25);
"""u8);
// Create a reader
using var reader = connection.ExecuteReader("""
SELECT name
FROM user
""");
// Read values using Read() / GetXXX(column)
while (reader.Read())
{
Console.WriteLine($"{reader.GetString(0)}!");
}
SqliteCommand
To reuse the same query, use SqliteCommand.
using var command = connection.CreateCommand("""
SELECT name
FROM user
""");
using var reader = command.ExecuteReader();
You can also add parameters to SqliteCommand.
using var command = conn.CreateCommand("INSERT INTO t(val) VALUES($foo);");
command.Parameters.Add("$foo", "foo");
command.ExecuteNonQuery();
Exception Handling
If any error occurs during execution, a SqliteException is thrown. You can handle exceptions by catching this.
try
{
// ...
}
catch (SqliteException ex)
{
Console.WriteLine(ex.ErrorCode);
Console.WriteLine(ex.Message);
}
License
This library is provided under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on CsSqlite.Native:
| Package | Downloads |
|---|---|
|
CsSqlite
Extremely fast, robust, and lightweight SQLite bindings for .NET and Unity |
GitHub repositories
This package is not used by any popular GitHub repositories.