Intro to SQLDelight
- 22-01-17
- 12 Comments
- HTML
The SQLDelight library is known for generating typesafe Kotlin APIs from SQL statements, according to its official documentation. With its schema verification, statements, and compile-time migrations, SQLDelignt provides IDE features that make writing and maintaining SQL easy. So what does SQLDelight do that other libraries don’t? Let’s take the most famous library for native Android development, Room, as an example. Both libraries wrap around the SQLite database, which prevents us from using the nightmarish SQLiteOpenHelper by providing Kotlin and Java APIs to reason about most of the CRUD operations with compile-time validation. Where SQLDelight separates itself is that it has cross-platform support apart from Android with the option to change the underlying database to MySQL, Postgress, or HSQL/H2. Using Kotlin Multiplatform Mobile, SQLDelight also provides cross-platform compatibility with platform-agnostic APIs to share business logic code across different platforms like Android, iOS, and more. And, SQLDelight provides syntax highlighting and autocompletion, migration testing and exporting, the ability to switch underlying databases for Java virtual machine (JVM) projects, and supports coroutines and RxJava. In this article, we will cover the following: Setting up SQLDelight Setting up and connecting to the database CRUD operations with Insert, Update, Select, and Delete queries using SQLDelight Transaction operations and atomic rollbacks
Leave Comment