drift/drift_sqflite
Simon Binder c72f2131f7
Prepare drift_sqflite release
2023-06-10 14:18:29 +02:00
..
android Update integration tests for drift_sqflite 2023-06-09 17:40:51 +02:00
example Delete example app from drift_sqflite 2022-04-02 19:42:06 +02:00
integration_test Update integration tests for drift_sqflite 2023-06-09 17:40:51 +02:00
ios Update ios, macos projects 2022-07-02 08:31:17 +02:00
lib Generate null variables 2022-09-19 22:43:16 +02:00
.gitignore First release of `drift_sqflite` 2022-03-14 21:51:43 +01:00
CHANGELOG.md Generate null variables 2022-09-19 22:43:16 +02:00
LICENSE First release of `drift_sqflite` 2022-03-14 21:51:43 +01:00
README.md First release of `drift_sqflite` 2022-03-14 21:51:43 +01:00
analysis_options.yaml Add `drift_sqflite` to replace `moor_flutter` 2022-03-14 20:27:19 +01:00
pubspec.yaml Prepare drift_sqflite release 2023-06-10 14:18:29 +02:00
test_asset.db Update integration test architecture 2022-06-25 14:06:56 +02:00

README.md

drift_sqflite

drift_sqflite contains a drift database implementation based on the sqflite package.

For more information on drift, see its documentation.

Usage

The SqfliteQueryExecutor class can be passed to the constructor of your drift database class to make it use sqflite.

@DriftDatabase(tables: [Todos, Categories])
class MyDatabase extends _$MyDatabase {
  // we tell the database where to store the data with this constructor
  MyDatabase() : super(_openConnection());

  // you should bump this number whenever you change or add a table definition.
  // Migrations are covered later in the documentation.
  @override
  int get schemaVersion => 1;
}

QueryExecutor _openConnection() {
  return SqfliteQueryExecutor.inDatabaseFolder(path: 'db.sqlite');
}

Note: The drift_sqflite package is an alternative to the standard approach suggested in the drift documentation (which consists of a NativeDatabase instead of SqfliteQueryExecutor). Using this package is primarily recommended when migrating existing projects off moor_flutter. When using a SqfliteQueryExecutor, you don't need to depend on sqlite3_flutter_libs like the drift documentation suggests for the standard approach.

Migrating from moor_flutter

The easiest way to migrate from moor_flutter to drift_sqflite is to use the automatic migration tool.