Skip to content

Using sqlite inside a long-lived isolate #22

Answered by rkistner
sabin26 asked this question in Q&A
Discussion options

You must be logged in to vote

You can use db.isolateConnectionFactory() to get a "factory" object to send over to different isolates, which allows you to open a connection in them:

/// A connection factory that can be passed to different isolates.
///
/// Use this to access the database in background isolates.
IsolateConnectionFactory isolateConnectionFactory() {
return IsolateConnectionFactory(
openFactory: openFactory,
mutex: mutex.shared,
upstreamPort: _eventsPort.client());
}

The factory then has a method IsolateConnectionFactory.openRawDatabase() that opens a synchronous connection:

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sabin26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants