A SQLite database contains a column with JSON data like the following:
MyTable
______________________________________
| specs | name | date
--------------------------------------
| ["foo","bar"] | Test01 | 2018-02-05
| ["foo","bar"] | Test02 | 2018-02-01
| ["foo"] | Test03 | 2018-02-03
Pseudo-code:
private static SQLiteConnection _sqliteDb;
using (var source = new SQLiteConnection($"Data Source={databasePath};Version=3;"))
{
source.Open();
_sqliteDb = new SQLiteConnection("Data Source=:memory:");
_sqliteDb.Open();
// copy db file to memory
source.BackupDatabase(_sqliteDb, "main", "main", -1, null, 0);
source.Close();
}
var cmd = new SQLiteCommand(query, _sqliteDb);
In order to filter on this column, the query looks like this:
var query = "SELECT * FROM MyTable, json_each(MyTable.specs) AS spec WHERE spec.value = 'bar'"
This error appears: SQLite error (1): no such table: json_each
How to use json1 extension with System.Data.SQLite.Core?
specsthe table name or the column name? (The other one is missing from the query.)