Skip to content

Commit 9b6d853

Browse files
committed
Add upgrade notes
1 parent c7e0a04 commit 9b6d853

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# sqlite3.dart
22

3+
> [!TIP]
4+
> This branch contains sources for version 3 of `package:sqlite3`, a major update
5+
> relying on build hooks and code assets to load SQLite.
6+
> Version 2 of `package:sqlite` will continue to be supported and updated until early 2026.
7+
> See the [v2](https://github.com/simolus3/sqlite3.dart/tree/v2) branch for those sources, and
8+
> [these notes](./UPGRADING_TO_V3.md) for details on how to upgrade.
9+
310
This project contains Dart packages to use SQLite from Dart via `dart:ffi`.
411

512
The main package in this repository is [`sqlite3`](sqlite3), which contains all the Dart apis and their implementation.

UPGRADING_TO_V3.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
## Upgrading `package:sqlite3`.
2+
3+
This document collects notes on upgrading the `sqlite3` package from version
4+
2.x to version 3.x.
5+
6+
For almost all users, upgrading should be very simple:
7+
8+
1. If you depend on `sqlite3_flutter_libs`, stop doing that.
9+
2. If you depend on `sqlcipher_flutter_libs`, stop doing that and read
10+
[encryption](#encryption).
11+
3. Upgrade to `sqlite3: ^3.0.0`.
12+
4. Make sure you update your `sqlite3.wasm` by downloading it from the
13+
[latest releases](https://github.com/simolus3/sqlite3.dart/releases).
14+
5. If you had `open.overrideFor` code to customize how SQLite is loaded, that needs
15+
to be removed. The package exclusively uses hooks now.
16+
17+
Version 3.x relies on [hooks](https://dart.dev/tools/hooks) to automatically bundle
18+
a pre-compiled version of SQLite with your application. By default, these binaries
19+
are downloaded from the GitHub releases of this package.
20+
This mechanism replaces the earlier scheme based on platform-specific build
21+
scripts.
22+
23+
If you want to compile SQLite yourself instead of relying on those downloaded
24+
binaries, see [custom SQLite builds](#custom-sqlite-builds).
25+
26+
Also note that the build definition for `sqlite3.wasm` has changed. New sources
27+
are available in [sqlite3_wasm_build](./sqlite3_wasm_build/).
28+
29+
## Encryption
30+
31+
If you've been using SQLCipher to use encrypted databases, note that SQLCipher is
32+
no longer available with version 3. However, a precompiled version of SQLite3MultipleCiphers
33+
can easily be enabled by adding this to your pubspec:
34+
35+
```yaml
36+
hooks:
37+
user_defines:
38+
sqlite3:
39+
source: sqlite3mc
40+
```
41+
42+
SQLite3MultipleCiphers should be compatible with existing databases created by SQLCipher when running the following statements from SQLite3MultipleCiphers:
43+
44+
```
45+
pragma cipher = 'sqlcipher';
46+
pragma legacy = 4;
47+
48+
pragma key = '...your key...';
49+
```
50+
51+
For details, see [hook options](./sqlite3/doc/hook.md).
52+
53+
## Custom SQLite builds
54+
55+
If you want to customize the SQLite build for `package:sqlite3`, there are two options:
56+
57+
1. Downloading `sqlite3.c` into your project and then following the "Custom SQLite builds"
58+
section of [hook options](./sqlite3/doc/hook.md).
59+
2. Using external build scripts (such as SwiftPM or CMake) to statically link SQLite into your
60+
Flutter application, and then following the "Alternatives" section of [hook options](./sqlite3/doc/hook.md).
61+
62+
For details, see [hook options](./sqlite3/doc/hook.md).
63+
64+
If these customization options don't meet your needs, please open an issue!

sqlite3/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
Provides Dart bindings to [SQLite](https://www.sqlite.org/index.html) via `dart:ffi`.
44

5+
> [!TIP]
6+
> Version 3 of `package:sqlite3` is a major update relying on build hooks and
7+
> code assets to load SQLite. Version 2 of `package:sqlite` will continue to be
8+
> supported and updated until early 2026.
9+
> See [these notes](../UPGRADING_TO_V3.md) for details on how to upgrade.
10+
511
## Using this library
612

713
Because this library uses [hooks](https://dart.dev/tools/hooks), it bundles SQLite with

sqlite3/example/repro.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import 'package:sqlite3/sqlite3.dart';
2+
3+
void main() {
4+
final db = sqlite3.open('example.db');
5+
print(db.select("pragma cipher = 'sqlcipher'"));
6+
print(db.select('pragma legacy = 4'));
7+
8+
print(db.select("pragma key = 'foo'"));
9+
print(db.select('SELECT * FROM foo;'));
10+
}

0 commit comments

Comments
 (0)