You are not logged in.
Pages: 1
Good night.
I saw that there is a function RowsToSQLite3.
How do I export JSON or ClientDataset for SQLite3?
Offline
There is no direct method AFAIR, outside the scope of the ORM.
You have to write your low level code.
The easiest is to use TSQLTableJSON for reading the JSON content.
It would be then easy to fill the SQlite3 DB with it.
Offline
Thank you by return.
In my case, the data are sent by the server and comes in JSON.
I would like to use the functions ready for ORM. JSON for TSQLTable I have no problems in doing so. Can You give me an example of how I export for SQLite3?
Offline
1. Create the TSQLRecord descendant corresponding to your table layout.
I will call it TSQLMyData below.
2. Define a model with this TSQLMyData and a SQlite3 ORM server - i.e. TSQLRestServerDB.
Fill the TSQLMyData table as in the SQlite3 DB from JSON:
var rec: TSQLMyData;
batch: TSQLRestBatch;
batch := TSQLRestBach.Create(aServer,TSQLMyData,10000);
rec := TSQLMyData.CreateAndFillPrepare(aJSONFromClient);
try
while rec.FillOne do
batch.add(rec,true); // may be (rec,true,true) if you want to have the same IDs
aServer.BatchSend(batch);
finally
batch.Free;
rec.Free;
end;
Offline
Thank you for your assistance.
My last question. As I transform my JSON in a ISQLDBRows?
Offline
Exemple:
Rows, Rows2: ISQLDBRows;
fJSONBuffer: RawUTF8;
Rows := Props.Execute(SQL,[],nil,True);
fJSONBuffer := Rows.FetchAllAsJSON(false);
Rows.free;
----> How do I to fJSONBuffer to Rows again?
----> like this -> Rows2 := JSONToRows(fJSONBuffer);
Offline
If you don't want to code it, it may be helpful to first convert the JSON data to CSV by using a tool like https://json-csv.com
Last edited by ruth (2015-02-08 12:49:02)
Offline
Pages: 1