{"id":15013791,"url":"https://github.com/ufoss-org/kotysa","last_synced_at":"2025-08-21T18:33:50.276Z","repository":{"id":39899960,"uuid":"267915708","full_name":"ufoss-org/kotysa","owner":"ufoss-org","description":"The idiomatic way to write type-safe SQL in Kotlin ","archived":false,"fork":false,"pushed_at":"2024-03-14T23:04:00.000Z","size":4007,"stargazers_count":121,"open_issues_count":14,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-25T14:53:45.853Z","etag":null,"topics":["android","coroutines","jdbc","kotlin","ktor","orm","quarkus","r2dbc","spring-boot","sql","sqlite","vertx-sql-client"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ufoss-org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-05-29T17:24:06.000Z","updated_at":"2024-11-21T01:12:52.000Z","dependencies_parsed_at":"2024-03-02T23:43:02.887Z","dependency_job_id":null,"html_url":"https://github.com/ufoss-org/kotysa","commit_stats":{"total_commits":360,"total_committers":1,"mean_commits":360.0,"dds":0.0,"last_synced_commit":"2b7ba2700dd80664239c0243b075acd2f2ba2064"},"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ufoss-org%2Fkotysa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ufoss-org%2Fkotysa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ufoss-org%2Fkotysa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ufoss-org%2Fkotysa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ufoss-org","download_url":"https://codeload.github.com/ufoss-org/kotysa/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230527875,"owners_count":18240052,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","coroutines","jdbc","kotlin","ktor","orm","quarkus","r2dbc","spring-boot","sql","sqlite","vertx-sql-client"],"created_at":"2024-09-24T19:44:47.218Z","updated_at":"2024-12-20T03:10:26.305Z","avatar_url":"https://github.com/ufoss-org.png","language":"Kotlin","funding_links":[],"categories":["数据库开发"],"sub_categories":[],"readme":"[![License: Unlicense](https://img.shields.io/github/license/ufoss-org/kotysa)](http://unlicense.org/)\n[![Maven Central](https://img.shields.io/maven-central/v/org.ufoss.kotysa/kotysa-core)](https://search.maven.org/artifact/org.ufoss.kotysa/kotysa-core)\n[![Kotlin](https://img.shields.io/badge/kotlin-1.9.10-blue.svg?logo=kotlin)](http://kotlinlang.org)\n\n# Kotysa\n\n\u003e A light ORM that offers the idiomatic way to write **Ko**tlin **ty**pe-**sa**fe SQL for JVM and Android\n\n- Kotysa supports various drivers : JDBC, R2DBC, Vertx sqlclient\n- Kotysa supports various database engines : PostgreSQL, MySQL, Microsoft SQL Server, MariaDB, Oracle, H2\n- Kotysa supports SqLite on Android\n\nSee the [project website](https://ufoss.org/kotysa/) for documentation and APIs.\n\n## Basic example\n\nKotysa is easy to use : 3 steps only\n\n### step 1 -\u003e Create Kotlin entities\n\ndata classes are great for that !\n\n```kotlin\ndata class Role(\n        val label: String,\n        val id: UUID = UUID.randomUUID()\n)\n\ndata class User(\n        val firstname: String,\n        val roleId: UUID,\n        val alias: String? = null,\n        val id: Int? = null\n)\n```\n\n### step 2 -\u003e Describe database model\n\nUse our type-safe Tables DSL to map your entities with the database tables,\nthis is the ORM (object-relational mapping) step\n\n```kotlin\nobject Roles : H2Table\u003cRole\u003e(\"roles\") {\n    val id = uuid(Role::id)\n        .primaryKey()\n    val label = varchar(Role::label)\n        .unique()\n}\n\nobject Users : H2Table\u003cUser\u003e(\"users\") {\n    val id = autoIncrementInteger(User::id)\n        .primaryKey(\"PK_users\")\n    val firstname = varchar(User::firstname, \"f_name\")\n    val roleId = uuid(User::roleId)\n        .foreignKey(Roles.id, \"FK_users_roles\")\n    val alias = varchar(User::alias)\n}\n\n// List all your mapped tables\nprivate val tables = tables().h2(Roles, Users)\n```\n\n### step 3 -\u003e Write SQL queries\n\nUse our type-safe SqlClient DSL, Kotysa executes SQL query for you !\n\n```kotlin\nval admins = (sqlClient selectFrom Users\n        innerJoin Roles on Users.roleId eq Roles.id\n        where Roles.label eq \"admin\"\n        ).fetchAll() // returns all admin users\n```\n\n**No annotations, no code generation, no proxy, no additional plugin, just regular Kotlin code ! No JPA, just pure SQL !**\n\n## Contributors\n\nContributions are welcome.\n\n* Compile Kotysa with a JDK 17.\n* You need a local docker, like docker-ce : some tests use testcontainers to start real databases like PostgreSQL, MySQL...\n\n1. Clone this repo\n\n```bash\ngit clone git@github.com:ufoss-org/kotysa.git\n```\n\n2. Build project\n\n```bash\n./gradlew clean build\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fufoss-org%2Fkotysa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fufoss-org%2Fkotysa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fufoss-org%2Fkotysa/lists"}