SqlDatabase class abstract

An abstract base class for SQL-based database implementations.

Provides shared insert, select, update, and delete implementations that use ph to emit the correct parameter placeholder (@key for named style, :key for colon style). Subclasses implement rawQuery and declare their paramStyle — the SQL-building logic adapts automatically.

Implemented types
Implementers
Available extensions

Constructors

SqlDatabase(DbConfig config)

Properties

config → DbConfig
final
hashCode → int
The hash code for this object.
no setterinherited
paramStyle → DbParamStyle
The SQL parameter placeholder style used by this driver.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() → Future<void>
Closes the database connection.
inherited
connect() → Future<void>
Establishes a connection to the database.
inherited
delete(String table, {required Map<String, dynamic> where}) → Future<DbResult>
Deletes one or more rows from the specified table.
override
insert(String table, Map<String, dynamic> data) → Future<DbResult>
Inserts a new row into the specified table.
override
insertBatch(String table, List<Map<String, dynamic>> rows) → Future<DbResult>
Inserts multiple rows into table in a single batch operation.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
ph(String key) → String
Returns the placeholder string for key based on paramStyle.
ping({Duration timeout = const Duration(seconds: 2)}) → Future<bool>
Returns true when the database answers a trivial query within timeout, false otherwise — never throws.
override
query(String table) → QueryBuilder

Available on QueryExecutor, provided by the DbQueryExtension extension

Returns a QueryBuilder targeting table.
rawQuery(String query, {Map<String, dynamic>? values}) → Future<DbResult>
Executes a raw SQL query and returns the result.
override
select(String table, {Map<String, dynamic>? where, int? limit, int? offset}) → Future<DbResult>
Retrieves data from the specified table.
override
toString() → String
A string representation of this object.
inherited
transaction<T>(Future<T> callback(DbTransaction tx)) → Future<T>
Runs callback inside a database transaction.
inherited
update(String table, Map<String, dynamic> data, {required Map<String, dynamic> where}) → Future<DbResult>
Updates one or more rows in the specified table.
override

Operators

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