Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
- SQLite session extension support: capture net row changes with `BeginChangeSet`/`CaptureChangeSet`,
apply them with `ApplyTo`, invert them with `Invert`, diff attached databases and inspect `Changes`
- Table filters for both capture and apply, plus conflict handling through `SQLiteChangeSetConflict`
- Managed virtual filesystem injection: `SQLiteVfs.Register`/`Unregister`, `ISQLiteVirtualFileSystem`
and `ISQLiteVirtualFile`, with a default `SQLiteFileSystem` implementation
- Native SQLCipher builds now enable `SQLITE_ENABLE_SESSION` and `SQLITE_ENABLE_PREUPDATE_HOOK`
on Windows, Linux, Android, iOS, tvOS, macOS and WebGL

Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This package provides the excelent [SQLite-net](https://github.com/praeclarum/sq
+ `SQLiteConnection.Deserialize` extension method for deserializing memory (`byte[]`, `NativeArray<byte>` or `ReadOnlySpan<byte>`) into an open database (reference: [SQLite Deserialization](https://www.sqlite.org/c3ref/deserialize.html)).
+ `SQLiteConnection.ImportCsvToTable` extension method for importing a CSV text stream as a new table inside the database.
+ Row-level changesets via the SQLite session extension: `BeginChangeSet`/`CaptureChangeSet`, `ApplyTo`, `Invert`, `Diff`, table filters and conflict handling.
+ Managed virtual filesystem injection through `SQLiteVfs.Register` and `ISQLiteVirtualFileSystem`, for platforms whose file APIs are not normal paths (for example WeChat's `FileSystemManager`).
- [SQLite3 Multiple Ciphers 2.1.3](https://github.com/utelle/SQLite3MultipleCiphers/releases/tag/v2.1.3) (based on [SQLite 3.50.1](https://sqlite.org/releaselog/3_50_1.html))
+ Supports encrypted databases
+ Enabled modules: [R\*Tree](https://sqlite.org/rtree.html), [Geopoly](https://sqlite.org/geopoly.html), [FTS5](https://sqlite.org/fts5.html), [Built-In Math Functions](https://www.sqlite.org/lang_mathfunc.html)
Expand Down Expand Up @@ -103,6 +104,34 @@ public class TestSQLite : MonoBehaviour
```


## Virtual filesystems
When a platform cannot open a database through a normal path (for example WeChat Mini Game's
`FileSystemManager`), register an `ISQLiteVirtualFileSystem` and open the connection with its
VFS name:
```cs
SQLiteVfs.Register("game", new MyVirtualFileSystem());

using var db = new SQLiteConnection(new SQLiteConnectionString(
"game.sqlite",
SQLiteOpenFlags.Create | SQLiteOpenFlags.ReadWrite,
storeDateTimeAsTicks: true,
vfsName: "game"));

db.CreateTable<Player>();
db.Insert(new Player { Name = "gilzoide" });
```
`ISQLiteVirtualFile` is random-access and synchronous: `Read`, `Write`, `Truncate`, `Sync` and
`Length`. SQLite also routes the database journal and temporary files through it.

Limitations:
- One connection per database file; a second open returns `SQLITE_BUSY`.
- WAL is not supported. Use `journal_mode=DELETE` (the default).
- Call `SQLiteVfs.Unregister` only after all connections using it are closed.

`SQLiteFileSystem` is the default `System.IO` implementation. WebGL builds can use the Emscripten
filesystem; WeChat needs an implementation backed by `FileSystemManager`'s synchronous
`openSync`/`readSync`/`writeSync`/`closeSync` APIs.

## License
SQLite-net for Unity first-party code is licensed under the [MIT license](LICENSE.txt).

Expand Down
Loading
Loading