https://kotlinlang.org logo
#http4k
Title
# http4k
g

grace

10/29/2023, 10:56 AM
hii i want to use http4k with postgres but i have no idea how to integrate it after scrambling through google 😂 can someone give me some hints or example
s

s4nchez

10/29/2023, 10:59 AM
http4k doesn't include database-related features, but you can check out @dmcg’s example (and watch his videos, too -

this one

may be a good starting point) for what we consider a sensible way of integrating database code in Kotlin.
👀 1
thank you color 1
👯‍♂️ 1
o

Oliver Eisenbarth

10/29/2023, 12:46 PM
Hey, This article might also be a good starting point, as it shows raw JBDC and using Exposed. https://betterprogramming.pub/testable-database-repositories-in-kotlin-36277c523140?gi=622d2b783c96
thank you color 1
❤️ 1
a

Andrew O'Hara

10/29/2023, 4:00 PM
Taking a step back here. The better question is more along the lines of "How do I use postgres with kotlin/java"? Only highly opinionated frameworks like spring, django, or rails will come with their own database integrations. For pretty much any SQL database in Java/Kotlin, the simplest solution is to use the built-in JDBC interface (with a suitable JDBC driver for postgres). However, as Oliver and Ivan pointed out, there are many framework-agnostic database tools out there, like Exposed, jOOQ, and SqlDelight. These tools don't always make things simpler, but they tend to be safer, and can be more maintainable at scale.
☝️ 3
thank you color 1
o

Oliver Eisenbarth

10/30/2023, 8:01 AM
Here's a comparison between Exposed and SqlDelight by Daniel M. Ramos https://www.47deg.com/blog/database-persistence-in-kotlin-part-1/
...just in case you like to read. Like Andrew said, getting started with JDBC is simple and simple is good. It's just me squirreling away information nuggets that I am happy to share. ☺️
🙏 2
4 Views