https://kotlinlang.org logo
#squarelibraries
Title
# squarelibraries
s

Sebastian Sellmair [JB]

11/10/2023, 3:41 PM
Hey Folks 👋 Is there any guidance on how to use SQLDelight with background threads? If I try to wrap my transaction with
Copy code
withContext(Dispatchers.IO) {
     database.transactionWithResult { 
          ...
     }
}
Then I see
Copy code
java.lang.IllegalStateException: Transaction objects (`TransactionWithReturn` and `TransactionWithoutReturn`) must be used only within the transaction lambda scope.
p

Paul Woitaschek

11/11/2023, 3:23 PM
Bitw you should limit the parallelism, or your will block threads due to the concurrency limit of the connection
s

Sebastian Sellmair [JB]

11/13/2023, 2:07 PM
due to the concurrency limit of the connection
What is the limit? Is it 1?
p

Paul Woitaschek

11/13/2023, 2:07 PM
For Android it’s 1 thread for writing and 4 for reading
s

Sebastian Sellmair [JB]

11/13/2023, 2:09 PM
Thank you 👍
p

Paul Woitaschek

11/13/2023, 2:16 PM
I didn’t find official documentations on the actual limit of WAL
And it’s probably device specific too for some vendors
@cb Where did you get the info on the SQLite connection limit from? https://github.com/chrisbanes/tivi/commit/9f990ec517685990d7b119d17788235cff3502c0
c

cb

11/13/2023, 2:29 PM
I don't remember tbh. I was probably just copying the Android configuration.
🙏 1
p

Paul Woitaschek

11/13/2023, 2:30 PM
I read it in another slack space but also couldn’t find any sources on this
4 Views