Skip to content

Installation

sqlx4k is published to Maven Central.

The suggested way to set up sqlx4k: the Gradle plugin adds the driver of your database and sets up the code generation (@Table, @Repository, compile-time validations and optimizations) for you, from a single sqlx4k { } block:

plugins {
    kotlin("multiplatform") // or kotlin("jvm")
    id("io.github.smyrgeorge.sqlx4k") version "1.17.0"
}

sqlx4k {
    driver = PostgreSQL // also: MySQL, MariaDB, SQLite, SQLiteCipher
    generatedCodePackage = "com.example.generated"
}

See Gradle plugin for all the options, such as the extensions and the code-generator arguments.

Using an AI coding agent?

Install the sqlx4k skill, so your agent (Claude Code, Codex, Cursor, Copilot, …) sets up the project and writes the code the recommended way:

npx skills add smyrgeorge/sqlx4k

See AI agents.

Without the plugin

Or add the driver of your database yourself:

implementation("io.github.smyrgeorge:sqlx4k-postgres:1.17.0")
implementation("io.github.smyrgeorge:sqlx4k-mysql:1.17.0")
implementation("io.github.smyrgeorge:sqlx4k-sqlite:1.17.0")
// SQLite with encryption.
implementation("io.github.smyrgeorge:sqlx4k-sqlite-cipher:1.17.0")

Note

The driver alone does not set up the code generation (@Table, @Repository, compile-time validations): use the plugin, or configure KSP yourself as described in Manual setup.

Modules

Module Description
sqlx4k The core API: drivers' common interfaces, statements, result sets, transactions, migrations.
sqlx4k-postgres The PostgreSQL driver.
sqlx4k-mysql The MySQL / MariaDB driver.
sqlx4k-sqlite The SQLite driver.
sqlx4k-sqlite-cipher The SQLCipher (encrypted SQLite) driver.
sqlx4k-codegen The KSP code generator for @Table entities and @Repository interfaces.
sqlx4k-codegen-test Generates in-memory repositories for unit tests.
sqlx4k-arrow Repository interfaces for Arrow (see Repositories).
sqlx4k-postgres-pgmq A client for the PostgreSQL Message Queue.
sqlx4k-gradle-plugin The Gradle plugin.