Write database-playground in Kotlin

Hello, I am new to Kotlin an want to rewrite last project in Kotlin. It is a database-playground:

https://main–tiny-blancmange-a5cd5e.netlify.app/

I used SVELTE an sql.js for it. My idea for this project is to use KTOR and HTMX. This time I want to use MySQL instead of SQLite. I have SQL dump files for the databases I want to use. Can you please point me in the right direction.

How can I use these dumpfiles to create the database in Kotlin?
I have only seen projects where data-classes are created for all entities in the database. Maybe I don’t need this, because I only want to return a html response for every database response.

Thank you very much for your help.

I think you just need to choose your database library. KTOR prompts you to use the JetBrains Exposed library, but I don’t think there’s any reason you have to use that library. Just use an existing library that you’re familiar with for MySQL, if you have any; I would recommend the Jdbi library.

Thank you very much. I’m sorry for responding so late.

I used JDBI and it worked well.
I already deployed a web-service with ktor and use it in my old js app.

Now I’m using the H2 Database, with this command

val jdbi = Jdbi.create("jdbc:h2:mem:$slqScriptName;MODE=MYSQL;DB_CLOSE_DELAY=-1;", "username", "")

but I want to switch to mysql.

I can use this

val jdbi = Jdbi.create( "jdbc:mysql://localhost:3306/$slqScriptNamecreateDatabaseIfNotExist=true&autoReconnect=true", "user", "password")

on my own computer but I don’t know how I can use it in a docker container. I’m currently using the official DOCKER-FILE that I found here:
https://ktor.io/docs/docker.html to deploy my app on render.com.

Thank you very much for your help.

We’re definitely veering out of Kotlin content here and into library-specific questions and Docker questions. :stuck_out_tongue:

If I’m understanding correctly, you’re saying your app will run inside a Docker container, and you want your app to be able to connect to a database running outside the Docker container? Honestly that’s a question for the Docker docs… there’s ways to make external things accessible to processes inside a Docker container, but I can’t remember how. I’d have to read the docs.