SQLDelight is a Kotlin database library that validates SQL schema, statements, and migrations at compile time, generating type-safe Kotlin query functions from labeled SQL files. It treats SQL as the source of truth for database definitions, catching schema errors during the build process before they reach production.
The library supports multiple database dialects including SQLite, MySQL, PostgreSQL, HSQL, and H2, and generates platform-specific code for Android, iOS, JVM, and JavaScript targets. It provides a platform-specific driver abstraction that handles database connectivity differences across environments, with connection pooling that reserves a dedicated connection for write operations while limiting concurrent readers.
SQLDelight assembles database schemas by applying numbered migration files in order, and generates typed Kotlin APIs that accept parameters and return structured results at runtime. For JavaScript targets, it offloads all database operations to a background web worker to prevent blocking the main thread. The library works with standard JDBC data sources, Android databases, and SQLite files or in-memory databases.