DbExecutor class abstract

Unified database execution interface across SQL backends.

Implemented by SqliteDbExecutor and PostgresDbExecutor to provide a driver-agnostic API for running queries, parameterized statements, transactions, and inspecting query logs.

Mirrors djangors_db::DbExecutor.

Example:

Future<void> createAndQuery(DbExecutor db) async {
  await db.execute('CREATE TABLE items (id INTEGER PRIMARY KEY, name TEXT)');
  await db.execute('INSERT INTO items (name) VALUES (?)', ['Widget']);
  final rows = await db.fetchAll('SELECT * FROM items');
}
Implementers

Constructors

DbExecutor()

Properties

dialect Dialect
The SQL Dialect handled by this database backend.
no setter
hashCode int
The hash code for this object.
no setterinherited
queryLog List<String>
Chronological history of recorded SQL queries executed on this connection.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() Future<void>
Closes the underlying database connection and disposes resources.
execute(String sql, [List parameters = const []]) Future<int>
Executes a DML/DDL statement sql with parameters and returns the count of affected rows.
fetchAll(String sql, [List parameters = const []]) Future<List<DbRow>>
Executes a sql query with optional parameters and returns all matching DbRow instances.
fetchOne(String sql, [List parameters = const []]) Future<DbRow>
Executes a sql query with optional parameters and returns exactly one matching DbRow.
fetchOptional(String sql, [List parameters = const []]) Future<DbRow?>
Executes a sql query with optional parameters and returns the first DbRow or null if empty.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
recordQuery(String sql, [List parameters = const []]) → void
Records a raw sql statement with its parameters in the in-memory queryLog.
toString() String
A string representation of this object.
inherited
transaction<R>(Future<R> callback(DbExecutor tx)) Future<R>
Executes callback inside an atomic database transaction.

Operators

operator ==(Object other) bool
The equality operator.
inherited