Hey all, what's the best way to plug-in a SQLDelig...
# compose-desktop
i
Hey all, what's the best way to plug-in a SQLDelight
SqlDriver
that is persistent and works on Desktop (Linux, Windows, MacOS)? Here's the Github repo. Best I can do is in-memory one:
Copy code
import app.cash.sqldelight.db.SqlDriver
import app.cash.sqldelight.driver.jdbc.sqlite.JdbcSqliteDriver
import ivy.Database

actual class SQLDelightDriverFactory {
    actual fun createDriver(): SqlDriver {
        val driver: SqlDriver = JdbcSqliteDriver(JdbcSqliteDriver.IN_MEMORY)
        Database.Schema.create(driver)
        return driver
    }
}
solved 2
m
What about
Copy code
JdbcSqliteDriver("jdbc:sqlite:${dbFilePath}")
i
I'm noob to Desktop, do you have any good sample/snippet for creating the DB file + getting its path?
We don't care about migrations or anything. Just need the minimal code to get it running simalrly to how it runs on Android via the SQLite driver
m
The
dbFilePath
is just a String with the path to your DB file.
i
Ahaa, and the JdbcSqliteDriver will handle the DB file creation itself?
m
Yes or you can also provide an already existing database file.
i
Thank you very much @Michael Paus! Appreciated - will try it out 🙂
233 Views