sqlite3_connection_pool 0.1.0 copy "sqlite3_connection_pool: ^0.1.0" to clipboard
sqlite3_connection_pool: ^0.1.0 copied to clipboard

High-performance async connection pool for SQLite on native platforms.

example/main.dart

import 'package:sqlite3/sqlite3.dart';
import 'package:sqlite3_connection_pool/sqlite3_connection_pool.dart';

void main() async {
  Database openDatabase() {
    return sqlite3.openInMemory();
  }

  final pool = SqliteConnectionPool.open(
    name: 'test.db',
    openConnections: () => PoolConnections(openDatabase(), [
      for (var i = 0; i < 5; i++) openDatabase(),
    ]),
  );

  {
    final exclusive = await pool.exclusiveAccess();
    await exclusive.writer.execute('CREATE TEMPORARY TABLE conn(id);');
    await exclusive.writer.execute('INSERT INTO conn VALUES (?)', ['writer']);

    for (final (i, reader) in exclusive.readers.indexed) {
      await reader.execute('CREATE TEMPORARY TABLE conn(id);');
      await reader.execute('INSERT INTO conn VALUES (?)', ['reader-$i']);
    }
    exclusive.close();
  }

  pool.close();
}
0
likes
160
points
9
downloads

Publisher

verified publishersimonbinder.eu

Weekly Downloads

High-performance async connection pool for SQLite on native platforms.

Repository (GitHub)
View/report issues

Topics

#sql #database #ffi #sqlite

Documentation

API reference

License

MIT (license)

Dependencies

code_assets, ffi, hooks, meta, sqlite3

More

Packages that depend on sqlite3_connection_pool