# Installation

sqlx4k is published to Maven Central.

## With the Gradle plugin (recommended)

The suggested way to set up sqlx4k: the [Gradle plugin](<https://smyrgeorge.github.io/sqlx4k/getting-started/gradle-plugin/index.md>) adds the driver of your database and sets up the [code generation](<https://smyrgeorge.github.io/sqlx4k/codegen/index.md>) (`@Table`, `@Repository`, compile-time validations and optimizations) for you, from a single `sqlx4k { }` block:

```kotlin
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](<https://smyrgeorge.github.io/sqlx4k/getting-started/gradle-plugin/index.md>) for all the options, such as the extensions and the code-generator arguments.

> [!TIP]
>
> **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:
>
> ```shell
> npx skills add smyrgeorge/sqlx4k
> ```
>
> See [AI agents](<https://smyrgeorge.github.io/sqlx4k/getting-started/ai-agents/index.md>).

## Without the plugin

Or add the driver of your database yourself:

```kotlin
implementation("io.github.smyrgeorge:sqlx4k-postgres:1.17.0")
```

```kotlin
implementation("io.github.smyrgeorge:sqlx4k-mysql:1.17.0")
```

```kotlin
implementation("io.github.smyrgeorge:sqlx4k-sqlite:1.17.0")
```

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

> [!NOTE]
>
> The driver alone does not set up the [code generation](<https://smyrgeorge.github.io/sqlx4k/codegen/index.md>) (`@Table`, `@Repository`, compile-time validations): use the plugin, or configure KSP yourself as described in [Manual setup](<https://smyrgeorge.github.io/sqlx4k/codegen/#manual-setup>).

## Modules

| Module | Description |
| --- | --- |
| `sqlx4k` | The core API: drivers' common interfaces, statements, result sets, transactions, migrations. |
| `sqlx4k-postgres` | The [PostgreSQL](<https://smyrgeorge.github.io/sqlx4k/databases/postgresql/index.md>) driver. |
| `sqlx4k-mysql` | The [MySQL / MariaDB](<https://smyrgeorge.github.io/sqlx4k/databases/mysql/index.md>) driver. |
| `sqlx4k-sqlite` | The [SQLite](<https://smyrgeorge.github.io/sqlx4k/databases/sqlite/index.md>) driver. |
| `sqlx4k-sqlite-cipher` | The [SQLCipher](<https://smyrgeorge.github.io/sqlx4k/databases/sqlcipher/index.md>) (encrypted SQLite) driver. |
| `sqlx4k-codegen` | The KSP [code generator](<https://smyrgeorge.github.io/sqlx4k/codegen/index.md>) for `@Table` entities and `@Repository` interfaces. |
| `sqlx4k-codegen-test` | Generates [in-memory repositories](<https://smyrgeorge.github.io/sqlx4k/codegen/in-memory-repositories/index.md>) for unit tests. |
| `sqlx4k-arrow` | Repository interfaces for [Arrow](<https://arrow-kt.io/>) (see [Repositories](<https://smyrgeorge.github.io/sqlx4k/codegen/repositories/#repository-interfaces>)). |
| `sqlx4k-postgres-pgmq` | A client for the [PostgreSQL Message Queue](<https://smyrgeorge.github.io/sqlx4k/extensions/pgmq/index.md>). |
| `sqlx4k-gradle-plugin` | The [Gradle plugin](<https://smyrgeorge.github.io/sqlx4k/getting-started/gradle-plugin/index.md>). |
