Home

Awesome

SQLite Key-Value Store for Unity

openupm

Key-Value Store implementation backed by the SQLite database engine.

Features

Dependencies

How to install

Either:

Basic usage

using Gilzoide.KeyValueStore.Sqlite;
using UnityEngine;

// 1. Instantiate a SqliteKeyValueStore with the desired path
var kvs = new SqliteKeyValueStore(Application.persistentDataPath + "/MySaveFile.db");


// 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();