DbPool.fromSettingsNoDatabase constructor

DbPool.fromSettingsNoDatabase({
  1. required String pathToSettings,
  2. int? overrideMax,
  3. int? overrideMin,
  4. Duration? overrideExcessDuration,
})

Create a DbPool from settings at pathToSettings ignoring the database name so no default schema is selected.

Use this for operations that create and drop schemas.

Note: you can't use DbPool() to fetch this pool.

The intended use case is to use this as a short lived alternate pool that you pass to withTransaction.

final pool = DbPool.fromSettingsNoDatabase(....);
withTransation(action: () async {
    restoreDatabase(pathToBackup: '/mybackup.sql');
}
, dbPool: pool
);
await pool.close();

You can override the min no. of connections in the pool by passing in overrideMin. This is mainly for unit testing. You can override the max no. of connections in the pool by passing in overrideMax. This is mainly for unit testing.

Implementation

factory DbPool.fromSettingsNoDatabase(
        {required String pathToSettings,
        int? overrideMax,
        int? overrideMin,
        Duration? overrideExcessDuration}) =>
    DbPool._fromSettingsWithOverrides(
      pathToSettings: pathToSettings,
      overrideMax: overrideMax,
      overrideMin: overrideMin,
      overrideExcessDuration: overrideExcessDuration,
      useDatabase: false,
    );