configureConnection method

void configureConnection(
  1. Database database,
  2. SqliteOpenOptions options
)

Runs pragmaStatements for a freshly opened connection,

Implementation

void configureConnection(
    sqlite.Database database, SqliteOpenOptions 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 {
        database.execute(statement);
        break;
      } on sqlite.SqliteException catch (e) {
        if (e.resultCode == sqlite.SqlError.SQLITE_BUSY && tries < 29) {
          continue;
        } else {
          rethrow;
        }
      }
    }
  }
}