SQLite provider for GadoNet.
This plugin provides the SQLite implementation for GadoNet, leveraging the Microsoft.Data.Sqlite ADO.NET library to offer a robust and efficient database interface for Godot 4.x.
- Godot 4.x (.NET/Mono edition).
- GadoNet core plugin installed and enabled.
- Install the
gado_netcore plugin and enable it. - Copy the
gado_sqlitedirectory into your project'sres://addons/folder or install via asset library. - Enable the GadoSQLite plugin in Project Settings > Plugins.
- The plugin will attempt to register the necessary NuGet dependencies. Ensure your
.csprojis updated by rebuilding the project.
Initialize the SQLite client by providing a connection string or using the helper for file paths.
# Quick initialization from a file path
var db = GadoSQLite.from_path("user://save_data.db")
# Manual initialization with a full connection string
var db = GadoSQLite.new("Data Source=res://database.db;Mode=ReadOnly")# Non-query execution
var rows = db.execute(
"INSERT INTO profiles (name, score) VALUES (@name, @score)",
{"@name": "Player1", "@score": 100}
)
# Query execution
var results = db.query("SELECT * FROM profiles WHERE score > @min", {"@min": 50})
for row in results:
print(row["name"], ": ", row["score"])
# Scalar execution
var total = db.scalar("SELECT COUNT(*) FROM profiles")Highly recommended for heavy operations to avoid blocking the main thread.
var results = await db.query_async("SELECT * FROM large_table")Manage atomic operations using the transaction API. The transaction object automatically rolls back if it goes out of scope without being committed.
var tx = db.begin_transaction()
tx.execute("UPDATE inventory SET quantity = quantity - 1 WHERE item_id = 5")
tx.execute("INSERT INTO logs (action) VALUES ('Item consumed')")
tx.commit()See LICENCE.md file.