A DSL of Vertx Data Access with Kotlin
suspend fun main() {
val vertx = Vertx.vertx()
//vertx api,create a AsyncClient
val client = MySQLClient.createShared(vertx, json {
obj(
"username" to "root",
"password" to "root",
"database" to "study"
)
})
//extension create a connection
client.connection {
queryJsonWithParams(json {
array(1)
}) {
//build a sql
sql {
this select all from "user" where "id" eql param
}
}.forEach {
println(it)
}
}.join()
client.close()
vertx.close()
}
If you just want to build a sql string with dsl, you can just download the SQL.kt and SQLBuilderExt.kt