QLite have an export json feature.
How do you do that withing Xojo ?
If not built-in, can it be done using the shell ? (both platforms)
QLite have an export json feature.
How do you do that withing Xojo ?
If not built-in, can it be done using the shell ? (both platforms)
There is no reference to exporting data as JSON on that page.
If you have JSON strings in a SQLite fields, those operations allow you to access specific values within those strings.
Var db As New SQLiteDatabase
db.Connect
db.ExecuteSQL("CREATE TABLE products ("+_
"id INTEGER PRIMARY KEY,"+_
"name TEXT NOT NULL,"+_
"details TEXT NOT NULL"+_
");")
db.ExecuteSQL("INSERT INTO products (name, details) VALUES "+_
"('Smartphone', '{""category"": ""Phones"", ""price"": 999.01, "+_
"""colors"": [""Black"", ""Blue"", ""White""]}');")
Var rs As RowSet = db.SelectSQL("SELECT name, "+_
"json_extract (details, '$.price') AS price FROM products;")
Break
Release Notes (look for 2015 and other entries)
@Rick_Araujo : Thank you. I will resume work on this after dinner.
The question was to export to JSON. But I keep the Import - in case I need it - .
I will red deeper later.
You should be able to bundle the sqlite3 executable with your app and then use a shell to export to JSON.
sqlite3 mydatabase.db -cmd ".mode json" "SELECT * FROM mytable;" > export.json
Tested on macOS from the command line and it works as expected.
You should build your own JSON string and dump the stream. I guess it is a bit complex.