If your csv file is from MS Excel, the easiest way is to use TStringList.CommaText.
Assuming that
1) your SQL Query has the following SQL statement,
insert into TableName (f1, f2, ... , fn) values (:f1, :f2, :f3, ... , :fn)
2) In your Excel file, the last column is filled in all rows.
3) All data format in the Excel file are correct (No characters in number field).
const
filename = '.....';
var
AStrList: TStringList;
InputFile: TextFile;
s : string;
i : integer;
begin
AStrList := TStringList.Create;
AssignFile (InputFile, filename);
Reset(Inputfile);
readln(inputfile, s); // if the first row has titles, you should have to read this line out.
while not eof(TextFile) do begin
readln(inputfile, s);
AStrList.CommaText := s;
SQLQuery1.Close;
SQLQuery1.Prepare;
for i := 0 to AStrList.Count-1 do
SQLQuery1.Params[i].AsString := AStrList[i];
// ... possibly start transaction ...
SQLQuery1.ExecSQL;
// ... transaction.commit...
end; // while
CloseFile (Inputfile);
AStrList.Free;
end;
If MySQL's systax of "insert" SQL is different, then you should modify it accordingly.
The style of reading text file is rather old-fashioned, but it's not a big deal.