unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, FireDAC.Stan.Intf, FireDAC.Stan.Option,
FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,
FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.SQLite,
FireDAC.Phys.SQLiteDef, FireDAC.Stan.ExprFuncs, FireDAC.VCLUI.Wait,
FireDAC.Phys.SQLiteWrapper.Stat, Data.DB, FireDAC.Comp.Client;
type
TForm1 = class(TForm)
FDConnection1: TFDConnection;
FDPhysSQLiteDriverLink1: TFDPhysSQLiteDriverLink;
procedure FDConnection1AfterConnect(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FDConnection1AfterConnect(Sender: TObject);
begin
var count : Integer;
// this will create mydb.sqlite if it does not exist
FDConnection1.ExecSQL('ATTACH DATABASE ''C:\Users\Public\Documents\mydb.sqlite'' AS mydb');
FDConnection1.ExecSQL('CREATE TABLE IF NOT EXISTs mydb.t1 (c1 TEXT)');
FDConnection1.ExecSQL('INSERT INTO mydb.t1 (c1) VALUES (lower(hex(randomblob(16))))');
count := FDConnection1.ExecSQLScalar('SELECT COUNT(*) FROM mydb.t1');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FDConnection1.Params.Database := ':memory:';
FDConnection1.Connected := true;
end;
end.