https://kotlinlang.org logo
Title
g

Guilherme Delgado

05/05/2021, 10:32 AM
Hello all, I’m using SLQDelight to create a DB. Everything is ok and works as expected, my question is: How can I avoid BD recreation every-time I run/kill my localhost server? 🤔 All my tables are created with
CREATE TABLE IF NOT EXISTS
so I assume the file is being deleted. How can I avoid that? Also, where’s the file located? I don’t have this problem in KMM projects (for android/ios), the BD is never deleted (only if I clean cache of course). Thanks!
Ok, it’s an easy “fix”, I was using in memory DB, of course it gets wiped clean between deploys. Just have to persist it physically, how? Simple:
//        DatabaseProvider.dbSetup(JdbcSqliteDriver(JdbcSqliteDriver.IN_MEMORY))
        DatabaseProvider.dbSetup(JdbcSqliteDriver("jdbc:sqlite:data.db"))
and a “data.db” file will be created in the project’s root.