https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
k

Kris Wong

02/11/2020, 8:17 PM
does anyone know if you need 1 database per thread when using SQL Delight on native?
this comment leads me to believe the answer is no:
Copy code
// In reality the database and driver above should be created a single time
// and passed around using your favourite dependency injection/service locator/singleton pattern.
a

alec

02/11/2020, 8:22 PM
if you are using any of the reactive apis (rxjava, flow) then you would need one database for the entire application
other than that there are no restrictions, its all immutable
k

kpgalligan

02/11/2020, 8:26 PM
On native, you absolutely should not try to create multiple connections outside of what SQLDelight would create. In the best case they’ll just block each other, but it won’t be any faster.
That statement is only maybe not true if you’ve got a bunch of threads reading, but haven’t tried to optimize that
k

Kris Wong

02/11/2020, 8:40 PM
i am just making sure I don't need one DB/driver per thread
b

basher

02/11/2020, 8:43 PM
Using WAL mode?
k

Kris Wong

02/11/2020, 8:44 PM
whatever the default is
b

basher

02/11/2020, 8:48 PM
Oh wait nvm. Yeah SQLDelight is supposed to handle this transparently
k

kpgalligan

02/11/2020, 9:54 PM
You definitely don’t need one per thread
🙌 1