Hey everyone! I'm trying to use SQLDelight for my ...
# multiplatform
s
Hey everyone! I'm trying to use SQLDelight for my KMP project (that supports Android, iOS, JVM for Desktop, and JS) There's one thing I'm kinda stuck at i.e. how to implement a non IN-MEMORY SQLDelight database for JVM (Desktop) without needing my user to set up anything on his system before installing my app? I'm following this doc: https://cashapp.github.io/sqldelight/1.5.4/jvm_sqlite/ And it mentions that we might wanna use Hikari (or any other DB connection manager) to connect to a local DB. But just like other platforms (Andorid, iOS, etc) I just want my user to install and start using the app without having to set up anything. So is that somehow possible in the case of JVM (Desktop) as well?
j
I don't see a Hikari mention on that page
I use
org.xerial:sqlite-jdbc:3.40.0.0
which bundles the sqlite native library
s
It's available on this page though: https://cashapp.github.io/sqldelight/1.5.4/jvm_mysql/
j
for mysql, yes
s
Understood.. actually I don't care about what system it is.. be it MYSQL, Postgres or anything.. my goal is to avoid the user having to set up a local db on his system.
I use
org.xerial:sqlite-jdbc:3.40.0.0
which bundles the sqlite native library
Thanks for this suggestion.. I'll try it out 🙂
@jw Apologies for bothering you, but do you have any code examples where you're generating
.db
files on JVM and using them with SQLDelight?
all you'd need to do for in-memory is change the JDBC string in
db.kt
to omit the path
i think that defaults to in-memory. otherwise there's a magic string like
jdbc:sqlite:in-memory:
or something
s
Right.. in-memory db is fairly straightforward to use.. the documentation is pretty helpful in that as well, but due to lack of some examples, I wasn't able to figure out how to generate a
.db
file on the user's end and use it in SQLDelight. I'm going through your dodo example to understand how you did it. Looks like there already exists a
1.db
file, I'll now be trying to understand how that file was generated.
j
there's a task you run
To generate a .db file from your latest schema, run the generateSqlDelightSchema task, which is available once you specify a schemaOutputDirectory, as described in the gradle.md. You should probably do this before you create your first migration.