open method
Implementation
@override
Future<SqlConnection> open(String? path, {String? key}) async {
void setup(Database db) {
if (key != null) db.execute("PRAGMA key = \"x'$key'\"");
if (path != null) db.execute('PRAGMA journal_mode = WAL');
db.execute('PRAGMA synchronous = NORMAL');
}
final QueryExecutor executor;
if (path == null) {
executor = NativeDatabase.memory(setup: setup);
} else if (background) {
executor = NativeDatabase.createInBackground(File(path), setup: setup, enableMigrations: false);
} else {
executor = NativeDatabase(File(path), setup: setup, enableMigrations: false);
}
final connection = DriftConnection(executor);
await connection.open();
return connection;
}