So what taazz suggested:
procedure TForm1.TestBtnClick(Sender: TObject);
begin
SQLScript1.Script.Text:='delete from albums; delete from songs;';
SQLScript1.Execute;
end;
(code untested, don't know if it compiles)
or you could use a regular sqlquery and .execsql it - once for each delete command
Yes, I had already done that after reading that tutorial website, and it did compile OK, but it didn't do anything until I added another line:
SQLScript1.Script.Text:='delete from albums; delete from songs;';
SQLScript1.Execute;
SQLTransaction1.Commit;
After I ran that, the tables appeared to be empty when I examined the database with SQLite Studio, but the file was still exactly the same size (approx 3.5Mb) as it was before all the records were deleted.
Then I remembered reading on that tutorial website about using the vacuum command after using the delete from table command to clear unused space, so I changed it to this:
SQLScript1.Script.Text:='delete from albums; delete from songs; vacuum;';
<--- added the vacuum command to the script SQLScript1.Execute;
SQLTransaction1.Commit;
That compiled OK too, but when I ran it, I got an error message: Cannot VACUUM from within a transaction.
When I googled that error message, I got a hit from an earlier post on this forum that listed a solution to that error, so I added it:
SQLScript1.Script.Text:='delete from albums; delete from songs;';
<--- removed the vacuum command from the script SQLScript1.Execute;
SQLTransaction1.Commit;
albumsConnection.ExecuteDirect('End Transaction');
albumsConnection.ExecuteDirect('vacuum');
<--- and added it back here albumsConnection.ExecuteDirect('Begin Transaction');
That worked perfectly. The file is now only 3072 bytes, the same size I get if I use SQLite Studio to erase all the data and vacuum the database.
So now it's on to figuring out how to import the updated data. From what I've looked at, it looks like the TSqlite3Dataset component might be easier to use. It looks like I can just use 2 datasets (and 2 datasources) to connect directly to the tables, then parse the updated data and use Append and Post to add new records to the tables.
Is it possible to mix TSqlite3Dataset and the SQLdb components that I used above?
Would I have to completely disable the SQLdb components before connecting the TSqlite3Datasets, or could I connect them to the tables at design time and do the emptying procedure listed above using the SQLdb components while the tables were connected to the TSqlite3Datasets?
Or even better, could I do the above table emptying procedure also with TSqlite3Datasets? It does have a SQL property, and a ExecSQL procedure, and it looks like it might even have the ExecuteDirect procedure. That would eliminate having to use the SQLdb stuff at all.
Thanks to everybody for all the help so far, and I would very much appreciate any opinions that anybody might have on the above questions.