does anyone know if you need 1 database per thread...
# multiplatform
k
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
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
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
i am just making sure I don't need one DB/driver per thread
b
Using WAL mode?
k
whatever the default is
b
Oh wait nvm. Yeah SQLDelight is supposed to handle this transparently
k
You definitely don’t need one per thread
🙌 1