Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ClasicRando/kdbc

Repository files navigation

kdbc Logo     kotlin logo

Database drivers using Kotlin™ to drive database communication. The library provides both blocking and non-blocking solutions for database communication. The coroutine based solution uses Ktor networking under the hood which implements non-blocking selector socket channel connections. For the blocking solution, basic java sockets (as seen in JDBC based libraries) are used to facilitate database communications. This library is heavily inspired by Rust's SQLx and the connection spec in C#.

Currently, there is only initial support for Postgresql and plans for other freely available databases, but other JDBC compliant databases might also be added in the future.

Importing Library

Gradle

dependencies {
    implementation("io.github.clasicrando:kdbc-postgresql:0.0.3")
}

Basic Usage

val connectOptions = PgConnectOptions(
      host = "localhost",
      port = 5342U,
      username = "username",
      password = "yourSecretPassword",
      applicationName = "MyFirstKdbcProject"
)
val connection = Postgres.asyncConnection(connectOption = connectOptions)
val text: String = connection.createQuery("SELECT 'KDBC Docs'")
    .fetchScalar()
println(text) // KDBC Docs
connection.createPreparedQuery("CALL your_stored_procedure($1, $2)")
    .bind(1)
    .bind("KDBC Docs")
    .execute()
connection.close()

About

Blocking and Non-Blocking Database drivers using Kotlin

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages