Key-Value Store - SQLite
Key-Value Store implementation backed by the SQLite database engine
com.gilzoide.key-value-store.sqlite Install via UPM
Add to Unity Package Manager using this URL
https://www.pkglnk.dev/track/gilzoide-sqlite.git README
SQLite Key-Value Store for Unity
Key-Value Store implementation backed by the SQLite database engine.
Features
- Easy to use API similar to
PlayerPrefs - Automatic management of transactions, optimizing throughput. Write operations are commited automatically once per frame.
- Custom serialization of complex objects (class/struct types), using Key-Value Store's serialization system
- Supports running
PRAGMAstatements for customization of the database - Supports running
VACUUMstatements manually
Dependencies
- Key-Value Store: interface used by this implementation, which also provides custom object serialization out of the box.
- SQLite-net: library for managing SQLite databases
How to install
Either:
- Use the openupm registry and install this package using the openupm-cli:
openupm add com.gilzoide.key-value-store.sqlite - Install using the Unity Package Manager with the following URL:
https://github.com/gilzoide/unity-key-value-store-sqlite.git#1.0.0-preview2 - Clone this repository or download a snapshot of it directly inside your project's
AssetsorPackagesfolder.
Basic usage
using Gilzoide.KeyValueStore.Sqlite;
using UnityEngine;
// 1. Instantiate a SqliteKeyValueStore with the desired path
var databasePath = $"{Application.persistentDataPath}/MySaveFile.db";
var kvs = new SqliteKeyValueStore(databasePath);
// 2. Set/Get/Delete values
kvs.SetBool("finishedTutorial", true);
kvs.SetString("username", "gilzoide");
Debug.Log("Checking if values exist: " + kvs.HasKey("username"));
Debug.Log("Getting values: " + kvs.GetInt("username"));
Debug.Log("Getting values with fallback: " + kvs.GetString("username", "default username"));
// Like C# Dictionary, this idiom returns a bool if the key is found
if (kvs.TryGetString("someKey", out string foundValue))
{
Debug.Log("'someKey' exists: " + foundValue);
}
kvs.DeleteKey("someKey");
// 3. Dispose of the SqliteKeyValueStore when done
// This ensures the database connection gets closed correctly
kvs.Dispose();
Total Installs
0
Last 30 daysUnique IPs
0
Approximate usersInstalls Over Time
Operating Systems
No data yet
Top Countries
No data yet
Git Versions
No data yet
Embed Install Badge
Add an install count badge to your README
Markdown
[](https://www.pkglnk.dev/pkg/gilzoide-sqlite)HTML
<a href="https://www.pkglnk.dev/pkg/gilzoide-sqlite"><img src="https://www.pkglnk.dev/badge/gilzoide-sqlite.svg?style=pkglnk" alt="pkglnk installs"></a>
No comments yet. Be the first!