3

Since I cannot obtain SQLiteOpenHelper instance from BriteDatabase, how can I create compiled insert/update/delete statement from my model? Methods that return SqlDelightStatement are marked as deprecated in SqlDelight 0.5.1. I'm using SqlBrite 0.8.0 and I see there's a BriteDatabase#executeInsert(String, SQLiteStatement) and so on.

Alexander Perfilyev
  • 6,739
  • 2
  • 17
  • 30

1 Answers1

3

EDIT December 27th 2016: SQLBrite version 1.1.0 and up now exposes its own getWritableDatabase()

It's worth noting that calling getWritableDatabase() can potentially create or migrate a database so make sure you're calling it from a background thread!

Anstrong
  • 734
  • 3
  • 7
  • Thanks! Do I need to call `close()` on database object? – Alexander Perfilyev Oct 26 '16 at 08:01
  • only once you're done using the database for good. If you close a database while SQLBrite is still being used you'll run into errors. So when your application is going to close you can call close – Anstrong Oct 26 '16 at 14:32
  • Would notifications still trigger if the write doesn't happen via the BriteDatabase? – dotgc Nov 07 '16 at 12:07
  • no, everything has to go through BriteDatabase if you want the reactive parts to work – Anstrong Nov 07 '16 at 21:06
  • @Anstrong is there any way to use `executeInsert` with conflict algorithm? – Alexander Perfilyev Dec 11 '16 at 09:39
  • 1
    yes, use the SQLite syntax for it: https://sqlite.org/lang_conflict.html looks like `INSERT ON CONFLICT IGNORE table (column) VALUES ('sample')` – Anstrong Dec 11 '16 at 18:13
  • It seems that SqlBrite has migrated to `SupportSQLiteDatabase` - making this solution non-feasible. If SqlDelight doesn't also migrate, it seems compatibility between these two libraries is already being deprecated. – methodsignature Dec 13 '17 at 21:33