SqliteConnection class
A connection to one SQLite database via package:sqlite3 (FFI).
SQLite is single-writer, so keep one connection per isolate. Because the driver is synchronous, the object handed to transaction callbacks is this same connection: statements issued elsewhere in the isolate while a transaction is open run inside it, exactly as with Laravel's single PDO handle.
- Inheritance
-
- Object
- ConnectionBase
- SqliteConnection
Constructors
- SqliteConnection.inMemory()
-
A fresh in-memory database. Ideal for tests: real SQL, no server.
factory
- SqliteConnection.open(String path)
-
Opens (creating if needed) the database file at
path.factory
Properties
- grammar → Grammar
-
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
-
queryLog
→ List<
QueryEvent> -
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- transactionDepth → int
-
no setteroverride
Methods
-
close(
) → Future< void> -
override
-
disableQueryLog(
) → void -
inherited
-
enableQueryLog(
) → void -
Start recording statements into queryLog. Useful in tests to assert
how many queries a code path issued.
inherited
-
execute(
String sql, [List< Object?> bindings = const []]) → Future<int> -
Runs INSERT/UPDATE/DELETE/DDL and returns the number of affected rows.
override
-
flushQueryLog(
) → void -
inherited
-
insertGetId(
String sql, List< Object?> bindings, {String? primaryKey}) → Future<Object?> -
Runs an INSERT and returns the generated primary key.
override
-
listen(
void listener(QueryEvent event)) → void -
Observe every statement (for logging, tracing, slow-query alerts).
inherited
-
logged<
R> (String sql, List< Object?> bindings, FutureOr<R> run()) → Future<R> -
Times
run, publishes a QueryEvent, and converts driver errors into QueryException carrying the SQL and bindings.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
select(
String sql, [List< Object?> bindings = const []]) → Future<List< Row> > -
Runs a SELECT and returns every row. Prefer the query builder's
chunk()/lazy()for large tables.override -
toString(
) → String -
A string representation of this object.
inherited
-
transaction<
R> (Future< R> body(Connection tx)) → Future<R> -
Runs
bodyinside a transaction: commits when it returns, rolls back and rethrows when it throws. Nested calls use savepoints.override -
wrapError(
Object error, String sql, List< Object?> bindings) → QueryException -
Adapters override to map driver errors (unique violations, ...).
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited