Installation¶
sqlx4k is published to Maven Central.
With the Gradle plugin (recommended)¶
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:
See AI agents.
Without the plugin¶
Or add the driver of your database yourself:
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. |