Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to SQLDelight

Introduction to SQLDelight

I have talked about SQLDelight, a library for Android that generates Java models from CREATE TABLE statements.

* https://github.com/square/sqldelight

F9856cc7a15ed2cb9e6ebfab41fdf1cf?s=128

Shohei Kawano

May 25, 2016
Tweet

Transcript

  1. Delightful Android DB Development shaunkawano

  2. Common DB implementation in Android

  3. https://developer.android.com/training/basics/data-storage/databases.html

  4. https://developer.android.com/training/basics/data-storage/databases.html

  5. https://developer.android.com/training/basics/data-storage/databases.html

  6. https://developer.android.com/training/basics/data-storage/databases.html

  7. https://developer.android.com/training/basics/data-storage/databases.html

  8. https://developer.android.com/training/basics/data-storage/databases.html

  9. • Very Boilerplate 
 Static final Strings, ContentValues.. • Java

    × SQL Mixed up • Very fragile
 “CREATE TABLE”, “INTEGER PRIMARY KEY”
  10. SQLDelight

  11. SQLDelight https://github.com/square/sqldelight

  12. SQLDelight • Static analysis of your SQL • Completely separated

    SQL from Java codes • Auto generated Java Models based on SQL
  13. Dependency

  14. Dependency https://github.com/square/sqldelight

  15. Dependency https://github.com/square/sqldelight

  16. IntelliJ Plugin https://github.com/square/sqldelight

  17. Create .sq File

  18. Create .sq File • com/your/package/model/Potatotip.java

  19. Create .sq File • com/your/package/model/Potatotip.java • sqldelight/com/your/package/model/ Potatotip.sq

  20. Create .sq File • com/your/package/model/Potatotip.java • sqldelight/com/your/package/model/ Potatotip.sq Same package

    as your model class!
  21. Potatotip.sq

  22. Completely separated SQL from Java codes sqlidelight/com/your/package/Potatotip.sq

  23. Static analysis of your SQL

  24. • Auto generated Java Models based on .sq file

  25. None
  26. None
  27. SQLDelight + AutoValue + Retrolambda

  28. Map Insert

  29. None
  30. SQLDelight https://github.com/square/sqldelight

  31. Delightful Android DB Development shaunkawano fin.