conn_pool 2.1.9
conn_pool #
Manages a pool of connections.
Shared pool #
Creating a pool #
Pool
requires an instance of ConnectionManager
to open and close connections.
In this article, we will use PostgresManager
for demonstration purposes.
final pool = SharedPool(PostgresManager('exampleDB'), minSize: 5, maxSize: 10);
Getting connection #
Connection<PostgreSQLConnection> conn = await pool.get();
PostgreSQLConnection db = conn.connection;
await db.execute(
"CREATE TABLE posts (id SERIAL PRIMARY KEY, name VARCHAR(255), age INT);");
Releasing the connection to the pool #
await conn.release();
Change log #
2.1.9 #
- Bug fix
2.1.5 #
- Minor improvements to
SharedPool
release
2.1.3 #
- Documentation
2.1.2 #
- Updated README
2.1.1 #
SharedPool
import 'package:conn_pool/conn_pool.dart';
main() {}
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies:
conn_pool: ^2.1.9
2. Install it
You can install packages from the command line:
with pub:
$ pub get
with Flutter:
$ flutter pub get
Alternatively, your editor might support pub get
or flutter pub get
.
Check the docs for your editor to learn more.
3. Import it
Now in your Dart code, you can use:
import 'package:conn_pool/conn_pool.dart';
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
60
|
Health:
Code health derived from static analysis.
[more]
|
98
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
100
|
Overall:
Weighted score of the above.
[more]
|
79
|
We analyzed this package on Dec 9, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.6.1
- pana: 0.13.1+4
Health suggestions
Fix lib/src/pool.dart
. (-1.49 points)
Analysis of lib/src/pool.dart
reported 3 hints:
line 26 col 40: Use =
to separate a named parameter from its default value.
line 26 col 57: Use =
to separate a named parameter from its default value.
line 57 col 19: Avoid empty catch blocks.
Fix lib/src/counted_set.dart
. (-1 points)
Analysis of lib/src/counted_set.dart
reported 2 hints:
line 71 col 9: Use isEmpty instead of length
line 86 col 22: DO use curly braces for all flow control structures.
Dependencies
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=2.0.0 <3.0.0 | ||
Dev dependencies | |||
test | ^1.3.0 |