Other Exporting Sqlite data

udg

Expert
Licensed User
Longtime User
Hi all,
which could be the preferable way to export some data from an internal sqlite table?
A bit of context. An app stores some data in one or more tables while the DB is initialized in DirInternal. A SELECT statement is needed to extract only some data. Columns are of different data types (mainly INTEGER and TEXT), but Text columns can contain multiline text (i.e. CRLF separates those few rows saved in a given Text field). BTW, multiline text comes from a Preference Dialog Multiline input box. I doubt the exported data would count an high number of records, but I could split it in several files if needed.

Given the above, would you go CSV, JSON or other format?

The resulting export should be attached to an email.
On the receiving end, a companion app will read the file and INSERT records in a dedicated table modeled similar to the exporting one.

ps: my first thought went to the command ".dump" but I guess there's no way to call it given the above scenario, right?

Thank you for your hints and comments

udg
 

Peter Simpson

Expert
Licensed User
Longtime User
Hello @udg,
In the past I have exported in both CSV (using pure code) and JSON (using JSON Generator). I personally preferred CSV simply because it was easier for me to create, but the one problem with exporting as a CSV file is that you have to make sure that there are no commas in the original string/data being exported (which is what I did).

If I were to go through that procedure again for another client, I would probably opt with exporting to JSON (because of commas), even though my personal preferred option is CSV.

As you already know, processing either format is as simple as 1 2 3...
 
  • Like
Reactions: udg
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
SQLiteToJSONTest.

There is a B4XPage (pagOtherApp) that simulates the second app in which to import data from file (JSON string)

EDIT:
It contains a typo: a useless call to the ImportJSONString routine that I forgot to delete.
Obviously it does not cause "damage", not even keeping it.
 

Attachments

  • SQLiteToJSONTest.zip
    19.2 KB · Views: 175
Last edited:
Upvote 0
Top