{$linklib c}

program sqlitetest;

{$mode objfpc}{$H+}

uses
  SysUtils, Classes, db, SQLiteDataset;
  
var
  Sqlite: TSqlite;
  f1, f2: TField;
  df: TDateField;
  dtf: TDateTimeField;
  i: integer;

begin
  Sqlite := TSQLite.create(nil);
  with Sqlite do begin
   Close;
   DataBase := ExtractFilePath(ParamStr(0)) + 'base1.db';
   TableName := 'table1';
// Method 1
    with FieldDefs do begin
      Clear;
      Add('Field1',ftString,10,False);
      Add('Field2',ftInteger,0,False);
      //Add('Address',ftMemo,0,False);
      Add('DateTime', ftDateTime, 0, False);
      Add('Date',ftDate,0,False);
    end;
   CreateTable;
   Open;
  end;
  f1:=Sqlite.FindField('Field1');
  f2:=Sqlite.FindField('Field2');
  df:=TDateField(Sqlite.FindField('Date'));
  dtf:=TDateTimeField(Sqlite.FindField('DateTime'));

  for i:=0 to 100 do begin
    Sqlite.Append;
    f1.AsString:=
      chr((i * 1 + 4)  mod 26 + 65)+
      chr((i * 2 + 5)  mod 26 + 65)+
      chr((i * 3 + 6)  mod 26 + 65);
    f2.AsLongint := i;
    df.AsDateTime := date;
    dtf.Value := Now;
    Sqlite.Post;
  end;
  Sqlite.Close;
  Sqlite.Free;
end.

