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.
- Inheritance
-
- Object
- SqliteConnection
- SqliteDatabase
Constructors
- SqliteDatabase({required String path, SqliteOptions options = const SqliteOptions()})
-
Open a SqliteDatabase.
factory
- SqliteDatabase.singleConnection(SqliteConnection connection)
-
Opens a SqliteDatabase that only wraps an underlying connection.
factory
- SqliteDatabase.withFactory(SqliteOpenFactory openFactory)
-
Advanced: Open a database with a specified factory.
factory
Properties
- closed → bool
-
Returns true if the connection is closed
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
isInitialized
→ Future<
void> -
no setter
- maxReaders → int
-
Maximum number of concurrent read transactions.
no setter
- openFactory → SqliteOpenFactory
-
Factory that opens a raw database connection in each isolate.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
updates
→ Stream<
UpdateNotification> -
Reports table change update notifications
no setterinherited
Methods
-
abortableReadLock<
T> (Future< T> callback(SqliteReadContext tx), {Future<void> ? abortTrigger, String? debugContext}) → Future<T> -
Takes a read lock, without starting a transaction.
inherited
-
abortableWriteLock<
T> (Future< T> callback(SqliteWriteContext tx), {Future<void> ? abortTrigger, String? debugContext}) → Future<T> -
Takes a global lock, without starting a transaction.
inherited
-
close(
) → Future< void> -
inherited
-
computeWithDatabase<
T> (Future< T> compute(CommonDatabase 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
-
executeMultiple(
String sql) → Future< void> -
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
-
getAutoCommit(
) → Future< bool> -
Returns true if auto-commit is enabled. This means the database is not
currently in a transaction. This may be true even if a transaction lock
is still held, when the transaction has been committed or rolled back.
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.
-
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
-
onChangeUnthrottled(
Iterable< String> ? tables, {bool triggerImmediately = true}) → Stream<UpdateNotification> -
Like onChange, but without a defaut throttle duration.
inherited
-
readLock<
T> (Future< T> callback(SqliteReadContext tx), {Duration? lockTimeout, String? debugContext}) → Future<T> -
Takes a read lock, without starting a transaction.
inherited
-
readTransaction<
T> (Future< T> callback(SqliteReadContext tx), {Duration? lockTimeout}) → Future<T> -
Open a read-only transaction.
inherited
-
refreshSchema(
) → Future< void> -
Ensures that all connections are aware of the latest schema changes applied (if any).
Queries and watch calls can potentially use outdated schema information after a schema update.
inherited
-
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
-
watchUnthrottled(
String sql, {List< Object?> parameters = const [], Iterable<String> ? triggerOnTables}) → Stream<ResultSet> -
Like watch, but without a default throttle.
inherited
-
withAllConnections<
T> (Future< T> block(SqliteWriteContext writer, List<SqliteReadContext> readers)) → Future<T> -
Locks all underlying connections making up this database, and gives
blockaccess to all of them at once. This can be useful to run the same statement on all connections. For instance, ATTACHing a database, that is expected to be available in all connections. -
writeLock<
T> (Future< T> callback(SqliteWriteContext tx), {Duration? lockTimeout, String? debugContext}) → Future<T> -
Takes a global lock, without starting a transaction.
inherited
-
writeTransaction<
T> (Future< T> callback(SqliteWriteContext tx), {Duration? lockTimeout}) → Future<T> -
Open a read-write transaction.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited