Read and write a database
Use the API in the SQLite namespace to read and write SQLite databases from editor scripts. The API is the same as that of sqlite-net.
Reference the assembly
Section titled “Reference the assembly”The com.amari-noa.sqlite-net-vpm assembly is editor-only and has Auto Referenced enabled. Scripts in an Editor folder that do not use an assembly definition (asmdef) can use it without any extra setup.
To use it from your own asmdef, add a reference as follows.
-
In the Project window, select your editor-only asmdef.
-
In the Inspector, click + under Assembly Definition References and select
com.amari-noa.sqlite-net-vpm. -
Click Apply.
Read and write a database
Section titled “Read and write a database”The following example creates a table, inserts a row, and queries it.
using SQLite;
public class Item{ [PrimaryKey, AutoIncrement] public int Id { get; set; }
public string Name { get; set; }}
// In an editor scriptusing (var db = new SQLiteConnection("Library/example.db")){ db.CreateTable<Item>(); db.Insert(new Item { Name = "sample" }); var items = db.Table<Item>().Where(x => x.Name == "sample").ToList();}Relative paths are resolved from the Unity project folder. For asynchronous access, use SQLiteAsyncConnection.
For details on the API, see the sqlite-net documentation.
Copyright (c) 2026 天鈴のあ
