John Aoussou
09/04/2022, 12:08 PMJohn Aoussou
09/04/2022, 12:09 PMsettings.gradle.kts
file:
pluginManagement {
repositories {
google()
gradlePluginPortal()
mavenCentral()
maven("<https://maven.pkg.jetbrains.space/public/p/compose/dev>")
}
plugins {
kotlin("multiplatform").version(extra["kotlin.version"] as String)
id("org.jetbrains.compose").version(extra["compose.version"] as String)
id("com.squareup.sqldelight").version("1.5.3")
}
}
build.gradle.kts
file:
plugins {
kotlin("multiplatform")
id("org.jetbrains.compose")
id("com.squareup.sqldelight")
}
sqldelight {
database("MyDatabase") { // This will be the name of the generated database class.
packageName = "delight-desktop"
}
}
...
kotlin {
jvm {
compilations.all {
kotlinOptions.jvmTarget = "11"
}
withJava()
}
sourceSets {
val jvmMain by getting {
dependencies {
implementation(compose.desktop.currentOs)
implementation("com.squareup.sqldelight:sqlite-driver:1.5.3")
}
}
val jvmTest by getting
}
}
Is it indeed in jvmMain
I'm supposed to create the sqldelight
directory?
Am I supposed to use in the driver the same database name as in the build.gradle.kts? (I tried that but it doesn't recognize the reference).
class DriverFactory {
fun createDriver(): SqlDriver {
val driver: SqlDriver = JdbcSqliteDriver(JdbcSqliteDriver.IN_MEMORY)
MyDatabase.Schema.create(driver)
return driver
}
}
hfhbd
09/04/2022, 12:14 PMsqldelight
in jvmMain. What do you mean with the driver?John Aoussou
09/04/2022, 12:16 PMval driver: SqlDriver = JdbcSqliteDriver(JdbcSqliteDriver.IN_MEMORY)
Database.Schema.create(driver)
Sorry, there was a mistake in my question: in the driver, should I use the same database name as in the build.gradle.kts?hfhbd
09/04/2022, 12:24 PMJohn Aoussou
09/04/2022, 12:26 PMhfhbd
09/04/2022, 12:26 PMhfhbd
09/04/2022, 12:27 PMval driver: SqlDriver = JdbcSqliteDriver("<jdbc://sqlite>:localhost/fooDB")
MyDatabase.Schema.create(driver)
John Aoussou
09/04/2022, 12:29 PMMyDatabase.Schema.create(driver)
but it says it doesn't know what "MyDatabase" is.hfhbd
09/04/2022, 12:30 PMJohn Aoussou
09/04/2022, 12:31 PMhfhbd
09/04/2022, 12:32 PMJohn O'Reilly
09/04/2022, 12:36 PMJohn Aoussou
09/04/2022, 12:40 PMJohn Aoussou
09/04/2022, 12:43 PMsqldelight {
Database { // This will be the name of the generated database class.
packageName = "com.example"
}
}
doesn't work, I have to use
database("MyDatabase") { // This will be the name of the generated database class.
packageName = "delight-desktop"
}
hfhbd
09/04/2022, 12:44 PMJohn Aoussou
09/04/2022, 2:05 PMJohn Aoussou
09/05/2022, 3:27 AMcom.surrus.peopleinspace.db
)oianmol
09/05/2022, 9:39 AMJohn Aoussou
09/05/2022, 10:16 AMJohn Aoussou
09/05/2022, 10:17 AM