{"id":17248764,"url":"https://github.com/nomisrev/kotlin-jdbc-dsl","last_synced_at":"2026-01-20T01:56:32.706Z","repository":{"id":197014459,"uuid":"697816973","full_name":"nomisRev/kotlin-jdbc-dsl","owner":"nomisRev","description":"A simple Kotlin DSL for `javax.sql.DataSource`","archived":false,"fork":false,"pushed_at":"2024-04-15T09:04:15.000Z","size":99,"stargazers_count":2,"open_issues_count":8,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-12T14:16:49.115Z","etag":null,"topics":["datasource","javax","jvm","kotlin","kotlin-dsl","sql"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nomisRev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2023-09-28T14:34:05.000Z","updated_at":"2023-12-04T10:15:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"9825a999-a750-4634-a6a9-3ecc27c31eef","html_url":"https://github.com/nomisRev/kotlin-jdbc-dsl","commit_stats":null,"previous_names":["nomisrev/kotlin-jdbc-dsl"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nomisRev%2Fkotlin-jdbc-dsl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nomisRev%2Fkotlin-jdbc-dsl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nomisRev%2Fkotlin-jdbc-dsl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nomisRev%2Fkotlin-jdbc-dsl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nomisRev","download_url":"https://codeload.github.com/nomisRev/kotlin-jdbc-dsl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247457696,"owners_count":20941905,"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":["datasource","javax","jvm","kotlin","kotlin-dsl","sql"],"created_at":"2024-10-15T06:42:05.599Z","updated_at":"2026-01-20T01:56:32.679Z","avatar_url":"https://github.com/nomisRev.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Module Kotlin JDBC DSL\n\nA tiny and simple wrapper around `javax.sql.DataSource` to make working directly with it a bit more convenient in Kotlin.  \n\n```text\nimplementation(\"io.github.nomisrev.jdbc:latest\")\n```\n\n## Why?\n\nIn a lot of cases I've needed very little functionality, and simply wanted to run some simple queries against a database.\nUsing an ORM was unnecessary for my use-cases, and I've from time-to-time implemented small wrappers around JDBC like this.\n\nSo now I'm exposing it as a micro-lib, so I (and you) can depend on it from a common place and benefit from this DSL style.\n\n## How\n\nThe DSL is exposes a `connection` DSL function on `javax.sql.DataSource`.\n\n\u003c!--- INCLUDE\nimport javax.sql.DataSource\n--\u003e\n```kotlin\nprivate val createUserTable: String =\n  \"\"\"CREATE TABLE IF NOT EXISTS users(\n       id BIGSERIAL PRIMARY KEY,\n       email VARCHAR(200) NOT NULL UNIQUE,\n       username VARCHAR(100) NOT NULL UNIQUE\n     )\"\"\".trimIndent()\n\nfun DataSource.createTable(): Int =\n  connection { update(createUserTable) }\n```\n\n\u003c!--- INCLUDE\nimport javax.sql.DataSource\n\ndata class User(val id: Long, val email: String, val username: String)\n--\u003e\n```kotlin\nprivate val selectUser: String =\n  \"\"\"SELECT email, username\n     FROM users\n     WHERE id = ?;\"\"\".trimIndent()\n\nfun DataSource.getUser(id: Long): User? =\n  connection {\n    queryOrNull(selectUser, { bind(id) }) {\n      User(id = id, email= string(), username = string())\n    }\n  }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnomisrev%2Fkotlin-jdbc-dsl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnomisrev%2Fkotlin-jdbc-dsl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnomisrev%2Fkotlin-jdbc-dsl/lists"}