talira

The SQL library for Kotlin

open sourceApache-2.0free

Exposed is JetBrains' lightweight SQL library and ORM for Kotlin, running on top of a JDBC or R2DBC driver. It offers two ways to work with a database: a typesafe DSL that wraps SQL, and a lightweight Data Access Object (DAO) API. It supports H2, MariaDB, MySQL, Oracle, PostgreSQL, Amazon Redshift (JDBC only), Microsoft SQL Server and SQLite, so an application can switch database engines with little or no change. Extension modules add encrypted columns, date-time types, JSON and JSONB, money types, schema migration utilities and starters for Spring Boot 3 and 4.

Problems it solves

  • query a SQL database from Kotlin with type checking instead of raw SQL strings
  • map Kotlin objects to database tables without a heavy ORM
  • switch my Kotlin app between PostgreSQL, MySQL and SQLite without rewriting queries
  • use reactive database access in a Kotlin backend

Features

  • typesafe SQL DSL
  • lightweight DAO API
  • JDBC and R2DBC drivers
  • H2, MariaDB, MySQL, Oracle, PostgreSQL, Redshift, SQL Server and SQLite
  • schema migration utilities
  • encrypted and hashed column types
  • JSON and JSONB column types
  • Spring Boot 3 and 4 starters

Limitations

  • Requires Kotlin 2.2 or newer1
  • The DAO API over R2DBC is an experimental preview whose API may change between releases1

Alternatives

The same job

These do what Exposed does.

  1. jOOQ Typesafe SQL query builder and code generator for Java
  2. sqlc Compile SQL to type-safe code
  3. Slick Functional Relational Mapping for Scala
  4. WCDB WeChat's cross-platform mobile database framework on SQLite

Compare Exposed with the top 3