test.pas 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. program test;
  2. uses sqlite,sqlitedb, strings,classes;
  3. var
  4. MySQL: TSQLite;
  5. SQL: String;
  6. i, j: Integer;
  7. a: TStringList;
  8. begin
  9. Writeln('Creating class');
  10. MySQL := TSQLite.Create('test.db');
  11. MySQL.BusyTimeout := 1000;
  12. // writeln(MySQL.Version);
  13. Writeln('Creating table');
  14. SQL := 'CREATE TABLE Test(No int, Nom varchar(32),Prenom varchar(32));';
  15. MySQL.Query(sql, nil);
  16. SQL := 'INSERT INTO Test VALUES(1,''Coursiere'', ''Olivier'');';
  17. if MySQL.IsComplete(sql) then
  18. begin
  19. Writeln('Inserting first row');
  20. MySQL.Query(sql, nil);
  21. end;
  22. SQL := 'INSERT INTO Test VALUES(2,''Jourde'', ''Eric'');';
  23. if MySQL.IsComplete(sql) then
  24. begin
  25. Writeln('Inserting second row') ;
  26. MySQL.Query(sql, nil);
  27. end;
  28. Writeln('Selecting rows') ;
  29. SQL := 'SELECT * FROM Test;';
  30. MySQL.Query(sql, nil);
  31. writeln('Fields Names -------------------');
  32. for i:=0 to MySQL.List_FieldName.count-1 do
  33. writeln(i,' -> ',MySQL.List_FieldName.Strings[i]);
  34. writeln('Fields -------------------');
  35. for i:=0 to MySQL.List_Field.count-1 do
  36. begin
  37. a:=TStringList(MySQL.List_Field.items[i]);
  38. write(i,' -> ');
  39. for j:=0 to a.count-1 do
  40. write(a.Strings[j],' ');
  41. writeln('');
  42. end;
  43. // Uncomment to remove table again.
  44. // SQL := 'DROP TABLE Test;';
  45. // MySQL.Query(sql, nil);
  46. MySQL.Free;
  47. end.