# Write database-playground in Kotlin

**URL:** <https://discuss.kotlinlang.org/t/write-database-playground-in-kotlin/28137>\
**Category:** Uncategorized\
**Created:** [February 13, 2024, 6:33pm UTC](https://discuss.kotlinlang.org/t/write-database-playground-in-kotlin/28137 "2024-02-13T18:33:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheGhostOfTomJoad](https://avatars.discourse-cdn.com/v4/letter/t/ecc23a/32.png) [@TheGhostOfTomJoad](https://discuss.kotlinlang.org/u/TheGhostOfTomJoad)\
**Post date:** [February 13, 2024, 6:33pm UTC](https://discuss.kotlinlang.org/t/write-database-playground-in-kotlin/28137/1 "2024-02-13T18:33:10Z")

</div>

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/](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.

---

<div class="post-metadata">

**Author:** ![Skater901](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/skater901/32/10163_2.png) [@Skater901](https://discuss.kotlinlang.org/u/Skater901)\
**Post date:** [February 14, 2024, 10:55am UTC](https://discuss.kotlinlang.org/t/write-database-playground-in-kotlin/28137/2 "2024-02-14T10:55:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![TheGhostOfTomJoad](https://avatars.discourse-cdn.com/v4/letter/t/ecc23a/32.png) [@TheGhostOfTomJoad](https://discuss.kotlinlang.org/u/TheGhostOfTomJoad)\
**Post date:** [February 25, 2024, 10:24am UTC](https://discuss.kotlinlang.org/t/write-database-playground-in-kotlin/28137/3 "2024-02-25T10:24:20Z")

</div>

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](https://ktor.io/docs/docker.html) to deploy my app on [render.com](http://render.com).

Thank you very much for your help.

---

<div class="post-metadata">

**Author:** ![Skater901](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/skater901/32/10163_2.png) [@Skater901](https://discuss.kotlinlang.org/u/Skater901)\
**Post date:** [March 1, 2024, 6:28am UTC](https://discuss.kotlinlang.org/t/write-database-playground-in-kotlin/28137/4 "2024-03-01T06:28:25Z")

</div>

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

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.
