项目作者: yumeTsukiiii

项目描述 :
A DSL of Vertx Data Access with Kotlin
高级语言: Kotlin
项目地址: git://github.com/yumeTsukiiii/vertx-ktx-sql.git
创建时间: 2019-05-16T01:38:02Z
项目社区:https://github.com/yumeTsukiiii/vertx-ktx-sql

开源协议:

下载


vertx-ktx-sql

This is a DSL of Vertx-Database-Access with Kotlin.

It’s very simple and lightweight, but it might be useful to you.

For example:

  1. suspend fun main() {
  2. val vertx = Vertx.vertx()
  3. //vertx api,create a AsyncClient
  4. val client = MySQLClient.createShared(vertx, json {
  5. obj(
  6. "username" to "root",
  7. "password" to "root",
  8. "database" to "study"
  9. )
  10. })
  11. //extension create a connection
  12. client.connection {
  13. queryJsonWithParams(json {
  14. array(1)
  15. }) {
  16. //build a sql
  17. sql {
  18. this select all from "user" where "id" eql param
  19. }
  20. }.forEach {
  21. println(it)
  22. }
  23. }.join()
  24. client.close()
  25. vertx.close()
  26. }

If you just want to build a sql string with dsl, you can just download the SQL.kt and SQLBuilderExt.kt

Support following function to append a sql keyword, but not all.

You can see more at SQL.kt

  • select
  • from
  • where
  • eql
  • insert_into
  • value
  • values
  • inner_join
  • left_join
  • right_join
  • update