Ive made a brand new search session using a different point of view and found an old entry in the forum with shared code. I took the second shared code (Classic Xojo Code) and add code befor and after what was shared.
My testing SQLite data base file is 164KB on disk (1969 entries with 11 fields/1 RecordSet). The ellapsed time is
648 Ticks only for the db read / json conversion. If I includ the save process, this time doubles (I issued a Return key press as soon as the OK button appears / no file name change) if I include the save to disk time (just to get an idea of the ellapsed time.
To do the same task for xml, the process time is less than 1 second (I do not used Ticks, but I checked a file creation / modification times
that are the same, same date / time including the seconds).
No, I do not recall the URL to the original Conversation / I thank the sharing persons / here is my current testing code (all in one PushButton as a lazy person !).
Xojo 2015r1 / El Capitan / MacBook Pro Mid-2014 / RAM: 8GB / SSD.
[code] Dim jsonArray As New JSONItem
Dim js As JSONItem
Dim dbFile As FolderItem
Dim db As New SQLiteDatabase
Dim SQLiteFT As New FileType
Dim dataRS As RecordSet
Dim Loop_Idx As Integer
// To compute the process time
Dim Ticks_Start As Integer
Dim Ticks_End As Integer
// Build a temporary SQLite FileType
SQLiteFT.Extensions = “sqlite;cdb;rdb”
SQLiteFT.Name = “SQLite Document”
// Icon_Pict = SQLiteFT.Icon()
// Get the file
dbFile = GetOpenFolderItem(SQLiteFT)
If dbFile = Nil Then Return
db.DatabaseFile = dbFile
If Not db.Connect Then
MsgBox("The database couldn’t be opened. Error: " + db.ErrorMessage)
// SQLite part
// Get the start ticks
Ticks_Start = Ticks
// dataRS = db.SQLSelect(“SELECT * FROM sqlite_master”) // Original code, changed to line below
dataRS = db.SQLSelect(“SELECT * FROM Foo”) // Replace Foo with your own Table name
// Loop thru the file
While Not dataRS.EOF
// Get a New JSONItem
js = new JSONItem
// Go thru the RecordSet
For Loop_Idx = 1 to dataRS.FieldCount
// Build the JSONItem
js.Value(dataRS.IdxField(Loop_Idx).Name) = dataRS.IdxField(Loop_Idx).Value
// Append a new entry into the array
// Read the next RecordSet
// Report the data to the TA (TextArea)
TA.Text = jsonArray.ToString
// Get the end ticks
Ticks_End = Ticks // 648 Ticks
// Export the data into a json file
Dim file As FolderItem
Dim fileStream As TextOutputStream
file = GetSaveFolderItem("", “MyInfo.json”)
If file <> Nil Then
fileStream = TextOutputStream.Create(file)
// Close the SQLdataBase
// Ticks_End = Ticks // Time doubles [I click in save as soon as possible]
// You can use GetFolderItem to avoid the Save dialog
// You can use End_Ticks to report the write ellapsed time
// I know that I get around 10 seconds process time for both cases.
// Report the process time:
MsgBox “” + EndOfLine + EndOfLine +_
“Start: " + Str(Ticks_Start) + " Ticks” + EndOfLine +_
“End: " + Str(Ticks_End) + " Ticks” + EndOfLine +_
“Ellapsed time: " + Str(Ticks_End - Ticks_Start) + " Ticks” + EndOfLine[/code]
Ignore the Ticks / Time ellapsing lines of code.
Also, there is no Try in the TextOutputStream (it is a code taken from the language reference, and I do not wanted to wast time to add it: this is a proof of concept code / texting code.
PS: if you found an error, have a trick to speed up the process, etc. Feel free to share it here, so the next person who search in the Forum wil get a better Classic example.
Now I have to write the Read json file / fill the Listbox (fill a SQLite Data Base file) from the above generated file.