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
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
sqlwithparametersand returns the count of affected rows. -
fetchAll(
String sql, [List parameters = const []]) → Future< List< DbRow> > -
Executes a
sqlquery with optionalparametersand returns all matching DbRow instances. -
fetchOne(
String sql, [List parameters = const []]) → Future< DbRow> -
Executes a
sqlquery with optionalparametersand returns exactly one matching DbRow. -
fetchOptional(
String sql, [List parameters = const []]) → Future< DbRow?> -
Executes a
sqlquery with optionalparametersand returns the first DbRow ornullif 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
sqlstatement with itsparametersin the in-memory queryLog. -
toString(
) → String -
A string representation of this object.
inherited
-
transaction<
R> (Future< R> callback(DbExecutor tx)) → Future<R> -
Executes
callbackinside an atomic database transaction.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited