open method

  1. @override
Database open(
  1. SqliteOpenOptions options
)
override

Opens a direct connection to a SQLite database connection and executes setup pragma statements to initialize the DB

Implementation

@override

/// Opens a direct connection to a SQLite database connection
/// and executes setup pragma statements to initialize the DB
Database open(SqliteOpenOptions options) {
  var db = openDB(options);

  // Pragma statements don't have the same BUSY_TIMEOUT behavior as normal statements.
  // We add a manual retry loop for those.
  for (var statement in pragmaStatements(options)) {
    for (var tries = 0; tries < 30; tries++) {
      try {
        db.execute(statement);
        break;
      } on sqlite.SqliteException catch (e) {
        if (e.resultCode == sqlite.SqlError.SQLITE_BUSY && tries < 29) {
          continue;
        } else {
          rethrow;
        }
      }
    }
  }
  return db;
}