SqliteDatabase class
A SQLite database instance.
Use one instance per database file. If multiple instances are used, update notifications may not trigger, and calls may fail with "SQLITE_BUSY" errors.
- Implemented types
- Mixed-in types
Constructors
- SqliteDatabase.new({required dynamic path, int maxReaders = defaultMaxReaders, SqliteOptions options = const SqliteOptions.defaults()})
-
Open a SqliteDatabase.
factory
- SqliteDatabase.withFactory(SqliteOpenFactory openFactory, {int maxReaders = defaultMaxReaders})
- Advanced: Open a database with a specified factory.
Properties
- closed → bool
-
Returns true if the connection is closed
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxReaders → int
-
Maximum number of concurrent read transactions.
final
- mutex → SimpleMutex
-
Global lock to serialize write transactions.
final
- openFactory → SqliteOpenFactory
-
Factory that opens a raw database connection in each isolate.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
updates
↔ Stream<
UpdateNotification> -
Use this stream to subscribe to notifications of updates to tables.
latefinaloverride-getter
Methods
-
close(
) → Future< void> -
override
-
computeWithDatabase<
T> (Future< T> compute(Database db)) → Future<T> -
See SqliteReadContext.computeWithDatabase.
inherited
-
execute(
String sql, [List< Object?> parameters = const []]) → Future<ResultSet> -
Execute a write query (INSERT, UPDATE, DELETE) and return the results (if any).
inherited
-
executeBatch(
String sql, List< List< parameterSets) → Future<Object?> >void> -
Execute a write query (INSERT, UPDATE, DELETE) multiple times with each
parameter set. This is more faster than executing separately with each
parameter set.
inherited
-
get(
String sql, [List< Object?> parameters = const []]) → Future<Row> -
Execute a read-only (SELECT) query and return a single result.
inherited
-
getAll(
String sql, [List< Object?> parameters = const []]) → Future<ResultSet> -
Execute a read-only (SELECT) query and return the results.
inherited
-
getOptional(
String sql, [List< Object?> parameters = const []]) → Future<Row?> -
Execute a read-only (SELECT) query and return a single optional result.
inherited
-
initialize(
) → Future< void> - Wait for initialization to complete.
-
isolateConnectionFactory(
) → IsolateConnectionFactory - A connection factory that can be passed to different isolates.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onChange(
Iterable< String> ? tables, {Duration throttle = const Duration(milliseconds: 30), bool triggerImmediately = true}) → Stream<UpdateNotification> -
Create a Stream of changes to any of the specified tables.
inherited
-
readLock<
T> (Future< T> callback(SqliteReadContext tx), {Duration? lockTimeout, String? debugContext}) → Future<T> -
Takes a read lock, without starting a transaction.
override
-
readTransaction<
T> (Future< T> callback(SqliteReadContext tx), {Duration? lockTimeout}) → Future<T> -
Open a read-only transaction.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
watch(
String sql, {List< Object?> parameters = const [], Duration throttle = const Duration(milliseconds: 30), Iterable<String> ? triggerOnTables}) → Stream<ResultSet> -
Execute a read query every time the source tables are modified.
inherited
-
writeLock<
T> (Future< T> callback(SqliteWriteContext tx), {Duration? lockTimeout, String? debugContext}) → Future<T> -
Takes a global lock, without starting a transaction.
override
-
writeTransaction<
T> (Future< T> callback(SqliteWriteContext tx), {Duration? lockTimeout}) → Future<T> -
Open a read-write transaction.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- defaultMaxReaders → const int
- The maximum number of concurrent read transactions if not explicitly specified.