I'm developing with Jetpack Compose Desktop and having a hard time finding any up to date information on what libraries are available for database storage. Room is obviously not an option. I have heard sqldelight is an option but not able to find any resources for setup. Thanks in advance.
Asked
Active
Viewed 140 times
0
-
compose is a UI toolkit, it doesn't restricts you in using any DB. if you only target desktop, you can use any JVM database(that doesn't have android dependencies, which I guess Room has). if you're sharing code with other platforms, [here](https://github.com/AAkira/Kotlin-Multiplatform-Libraries#storage) is a list of KMP libraries available. – Phil Dukhov Aug 04 '23 at 03:38
-
Thanks Phil. I will check that out – Jaz Aug 04 '23 at 22:17
1 Answers
0
I use SqlDelight in Desktop app build with Kotlin and Compose UI. Here is a resource might help to you as well:
https://cashapp.github.io/sqldelight/2.0.0/multiplatform_sqlite/
Build.gradle.kts
kotlin {
jvm {
jvmToolchain(Deps.JDK)
withJava()
}
sourceSets {
val commonMain by getting {
dependencies {
implementation(Deps.Koin.CORE)
//Database
with(Deps.SQLDelight) {
implementation(DRIVER)
api(RUNTIME)
api(COROUTINE_EXT)
}
}
}
val jvmMain by getting
}
}
sqldelight {
databases {
create("AppDatabase") {
packageName.set("com.mobiledevpro.database")
}
}
}
object SQLDelight {
const val DRIVER = "app.cash.sqldelight:sqlite-driver:${Versions.SQL_DELIGHT}"
const val RUNTIME = "app.cash.sqldelight:runtime:${Versions.SQL_DELIGHT}"
const val COROUTINE_EXT = "app.cash.sqldelight:coroutines-extensions:${Versions.SQL_DELIGHT}"
}

Dmitri Chernysh
- 260
- 1
- 7
-
Thanks Dmitri, it looks as though that's for multiplatform and not not Desktop. Were you able to use the same libraries for SqlDelight in Desktop? – Jaz Aug 03 '23 at 21:19
-
Yes, I was. I use exactly the same. Compose Multiplatform is just a UI framework over the Kotlin Multiplatform. "app.cash.sqldelight:sqlite-driver:${Versions.SQL_DELIGHT}" "app.cash.sqldelight:runtime:${Versions.SQL_DELIGHT}" "app.cash.sqldelight:coroutines-extensions:${Versions.SQL_DELIGHT}" – Dmitri Chernysh Aug 03 '23 at 21:29
-
By that I mean specifically a "Compose for Desktop" app, not "Kotlin Multiplatform"? Thanks – Jaz Aug 03 '23 at 21:31
-
Compose for Desktop is just UI framework built over Kotlin Multiplatform, so you could use SQLDelight – Dmitri Chernysh Aug 03 '23 at 21:35