Questions tagged [sqldelight]

SQLDelight generates Java models from your SQL statements. These models give you a typesafe API to read & write the rows of your tables. It helps you to keep your SQL statements together, organized, and easy to access from Java.

SQLDelight generates typesafe APIs from your SQL statements. It compile-time verifies your schema, statements, and migrations and provides IDE features like autocomplete and refactoring which make writing and maintaining SQL simple. SQLDelight currently supports the SQLite dialect and there are supported SQLite drivers on Android, JVM and iOS.

The premise of SQLDelight is unchanged: Write SQLite and let the Gradle plugin generate APIs to run your queries for you. SQLDelight files use the .sq extensions and are contained in your src/main/sqldelight folder in a Gradle module.

122 questions
15
votes
4 answers

Sqldelight database schema not generated

I have a KMM project and want to use SqlDelight library, but when I build the project database schema not generated and table entities also. actual class DatabaseDriverFactory(private val context: Context) { actual fun createDriver(): SqlDriver…
Jemo Mgebrishvili
  • 5,187
  • 7
  • 38
  • 63
14
votes
1 answer

Duplicate content roots detected

Android Studio gives me the following error code after I copied my project. Duplicate content roots detected: Path [/home/addi/AndroidStudioProjects/appfolder/appname/app/build/generated/sqldelight/code/Database/debug] of module [appname.app.main]…
TightPhysics
  • 161
  • 1
  • 2
  • 7
12
votes
2 answers

Repository pattern with SqlBrite/SqlDelight(Offline database) and Retrofit(Http request)

I am implementing repository pattern in RxJava using SqlBrite/SqlDelight for offline data storage and retrofit for Http requests Here's a sample of that: protected Observable> getItemsFromDb() { return…
Prithvi Bhola
  • 3,041
  • 1
  • 16
  • 32
10
votes
1 answer

Get row id for inserted row in sqldelight

I'm trying to use sqldelight to insert an item, but to also return the id of the item after it's inserted. There doesn't seem to be a way to do this in sqldelight. I can call something like SELECT last_insert_rowid(); after I do the insert, but is…
spierce7
  • 14,797
  • 13
  • 65
  • 106
8
votes
1 answer

Sqldelight 1.4 how insert filled data generated object without primarykey (id)

I have problem with saving data to sqldelight 1.4 in Android app. I created table: CREATE TABLE myTable( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT ); In repo class I have insert function with myTable object as an argument fun…
mlody92
  • 83
  • 1
  • 6
8
votes
1 answer

SQLDelight slow performance compared to Room

We want to migrate our App from Room to SQLDelight to reuse it on iOS (it is a Multiplatform project). I noticed however that SQLDelight is much slower than Room. For some queries it is around 10 times slower. I did some in depth testing with insert…
8
votes
2 answers

How to see/update database version? Is there something like "fallbackToDestructiveMigration"?

After modifying the sq file by renaming one of the tables and adding one more table I didn't find any place to specify that database schema or version has been changed and I want no migration - just recreate database. The documentation on official…
Marat
  • 6,142
  • 6
  • 39
  • 67
7
votes
1 answer

How to perform queries in background thread?

I'm currently looking at having a KMM application backed by SQLdelight for all domain-related operations. SQLdelight seems to provide really nice interfaces, however it seems like all the write calls (insert/update/delete) are implemented using…
7
votes
1 answer

"Unresolved reference: NativeSqliteDriver" for sqldelight added to ios source set

I am working on kotlin multiplatform project. I successfully added several libs to my build.gradle (ktor, coroutines, ...). I also added sqldelight to common, android and ios sourcesets. My ios dependency is defined like this: implementation…
DixieFlatline
  • 7,895
  • 24
  • 95
  • 147
7
votes
1 answer

What are the fundamental differences between Android Room and Sqldelight?

Ignoring multiplatform advantages, is there any advantage of using room over sqldelight?
Newbie
  • 7,031
  • 9
  • 60
  • 85
6
votes
2 answers

SQLDelight Migration

I am trying to add more columns in table in SQLDelight. I have made a migration file 1.sqm. In migration file it gives error that no table found. My build.gradle.kts: sqldelight { database("AppDatabase") { packageName =…
6
votes
0 answers

No proper documentation on how to migrate the existing DB in SQLDelight

In some of the stack overflow answers say 1.create new table and drop old tables. how to do that? 2.what is the use of sqm file and when we need to use? 3.what's is the use of deriveSchemaFromMigrations flag while declaring the sqllight db in…
SreekanthI
  • 393
  • 3
  • 13
5
votes
0 answers

how can we observe specific changes made to SQLDeLight DB and emit them?

This is my table structure CREATE TABLE Missions( MissionID INTEGER NOT NULL UNIQUE, MilestoneID INTEGER NOT NULL, MissionExpiry TEXT, MissionStatus TEXT, Count INTEGER DEFAULT 0, MilestoneList TEXT, UpdatedTime TEXT, …
Sushma K
  • 51
  • 2
5
votes
1 answer

SQLDelight and data classes with one to many relations in Kotlin

I am trying to create a small app using Kotlin Multiplatform where i can save book titles and their authors but i'm struggling with the data classes and how to map them together so that i get the author with all of their books and the publish…
Andy
  • 53
  • 3
5
votes
1 answer

SQLDelight Relationships

I want to model relationships with SQLDelight, especially a one to many relationship. I have 2 tables: recipe and ingredient. For simplicity they look like this: CREATE TABLE recipe ( id INTEGER NOT NULL PRIMARY KEY, name TEXT NOT NULL ) CREATE…
dipdipdip
  • 2,326
  • 1
  • 21
  • 31
1
2 3
8 9