DbPool class
A pool of database connections.
Constructors
- DbPool()
-
factory
- DbPool.fromArgs({required String host, required String database, required String user, required String password, int port = 3306, int minSize = 5, int maxSize = 50, bool useSSL = true})
-
factory
- DbPool.fromEnv()
-
factory
- DbPool.fromSettings({required String pathToSettings, int? overrideMax, int? overrideMin, Duration? overrideExcessDuration})
-
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 inoverrideMax
. This is mainly for unit testing.factory - DbPool.fromSettingsNoDatabase({required String pathToSettings, int? overrideMax, int? overrideMin, Duration? overrideExcessDuration})
-
Create a DbPool from settings at
pathToSettings
ignoring the database name so no default schema is selected.factory
Properties
- database → String?
-
Returns the database name this pool is attached to.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- open ↔ bool
-
The DbPool is open.
getter/setter pair
-
pool
→ SharedPool<
Db> -
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → int
-
returns the no. of connections currently in the pool
no setter
Methods
-
close(
) → Future< void> -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
obtain(
) → Future< ConnectionWrapper< Db> > - obtains a wrapper containg a Db connection
-
release(
ConnectionWrapper< Db> wrapper) → Future<void> -
relase the given connection
wrapper
back into the pool. -
toString(
) → String -
A string representation of this object.
inherited
-
withDb<
T> ({required Future< T> action(Db db)}) → Future<T> - Runs action passing in a Db from the pool
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- mysqMaxPoolSizeKey ↔ String
-
getter/setter pair
- mysqMinPoolSizeKey ↔ String
-
getter/setter pair
- useSSLKey ↔ String
-
getter/setter pair