diff --git a/Examples/Lazarus/lazarus.ico b/Examples/Lazarus/lazarus.ico
new file mode 100644
index 0000000..0341321
Binary files /dev/null and b/Examples/Lazarus/lazarus.ico differ
diff --git a/Examples/Lazarus/lazarus.lpi b/Examples/Lazarus/lazarus.lpi
new file mode 100644
index 0000000..6b949e1
--- /dev/null
+++ b/Examples/Lazarus/lazarus.lpi
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/Lazarus/lazarus.lpr b/Examples/Lazarus/lazarus.lpr
new file mode 100644
index 0000000..c9abff7
--- /dev/null
+++ b/Examples/Lazarus/lazarus.lpr
@@ -0,0 +1,21 @@
+program Lazarus;
+
+{$mode objfpc}{$H+}
+
+uses
+ {$IFDEF UNIX}{$IFDEF UseCThreads}
+ cthreads,
+ {$ENDIF}{$ENDIF}
+ Interfaces, // this includes the LCL widgetset
+ Forms, Main
+ { you can add units after this };
+
+{$R *.res}
+
+begin
+ RequireDerivedFormResource := True;
+ Application.Initialize;
+ Application.CreateForm(TForm_Main, Form_Main);
+ Application.Run;
+end.
+
diff --git a/Examples/Lazarus/lazarus.lps b/Examples/Lazarus/lazarus.lps
new file mode 100644
index 0000000..3495f21
--- /dev/null
+++ b/Examples/Lazarus/lazarus.lps
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/Lazarus/lazarus.res b/Examples/Lazarus/lazarus.res
new file mode 100644
index 0000000..7c6cf3e
Binary files /dev/null and b/Examples/Lazarus/lazarus.res differ
diff --git a/Examples/Lazarus/main.lfm b/Examples/Lazarus/main.lfm
new file mode 100644
index 0000000..5c25080
--- /dev/null
+++ b/Examples/Lazarus/main.lfm
@@ -0,0 +1,53 @@
+object Form_Main: TForm_Main
+ Left = 394
+ Height = 396
+ Top = 139
+ Width = 657
+ Caption = 'Lazarus SQLite Example'
+ ClientHeight = 396
+ ClientWidth = 657
+ Position = poScreenCenter
+ LCLVersion = '1.1'
+ object Memo_Result: TMemo
+ Left = 154
+ Height = 396
+ Top = 0
+ Width = 503
+ Align = alClient
+ BorderStyle = bsNone
+ Color = 4207920
+ Font.Color = 16773344
+ ParentFont = False
+ ScrollBars = ssVertical
+ TabOrder = 0
+ end
+ object Panel_Actions: TPanel
+ Left = 0
+ Height = 396
+ Top = 0
+ Width = 154
+ Align = alLeft
+ BevelOuter = bvNone
+ ClientHeight = 396
+ ClientWidth = 154
+ TabOrder = 1
+ object Button_DB_Read: TButton
+ Left = 8
+ Height = 33
+ Top = 48
+ Width = 136
+ Caption = 'Read Database'
+ OnClick = Button_DB_ReadClick
+ TabOrder = 0
+ end
+ object Button_DB_Create: TButton
+ Left = 8
+ Height = 33
+ Top = 8
+ Width = 136
+ Caption = 'Create Database'
+ OnClick = Button_DB_CreateClick
+ TabOrder = 1
+ end
+ end
+end
diff --git a/Examples/Lazarus/main.pas b/Examples/Lazarus/main.pas
new file mode 100644
index 0000000..8ab5732
--- /dev/null
+++ b/Examples/Lazarus/main.pas
@@ -0,0 +1,225 @@
+unit Main;
+
+{$MODE DELPHI}
+
+interface
+
+uses
+ Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
+ ExtCtrls;
+
+type
+
+ { TForm_Main }
+
+ TForm_Main = class(TForm)
+ Panel_Actions: TPanel;
+ Button_DB_Read: TButton;
+ Button_DB_Create: TButton;
+ Memo_Result: TMemo;
+ procedure Button_DB_CreateClick(Sender: TObject);
+ procedure Button_DB_ReadClick(Sender: TObject);
+ end;
+
+var
+ Form_Main: TForm_Main;
+
+implementation
+
+uses
+ SQLite3, SQLite3Wrap;
+
+{$R *.lfm}
+
+{ TForm_Main }
+
+procedure TForm_Main.Button_DB_CreateClick(Sender: TObject);
+var
+ DB: TSQLite3Database;
+ Stmt: TSQLite3Statement;
+ IDs: array[1..6] of Integer;
+begin
+ // Delete database if it already exists
+ DeleteFile('artists.db');
+
+ // Create datatbase and fill it with example data
+ DB := TSQLite3Database.Create;
+ try
+ DB.Open('artists.db');
+
+ // Create table "artists"
+ DB.Execute('CREATE TABLE artists (name TEXT, born REAL, died REAL)');
+
+ // Fill the table with artists
+ Stmt := DB.Prepare('INSERT INTO artists (name, born, died) VALUES (?, ?, ?)');
+ try
+ Stmt.BindText (1, 'Leonardo da Vinci');
+ Stmt.BindDouble(2, EncodeDate(1452, 4, 15));
+ Stmt.BindDouble(3, EncodeDate(1519, 5, 2));
+
+ Stmt.StepAndReset; // StepAndReset executes a prepared statement
+ // and resets it so we can reuse it again
+
+ IDs[1] := DB.LastInsertRowID; // Save newly added artist's ID to use it
+ // when filling "paintings" table below
+
+ Stmt.BindText (1, 'Raphael');
+ Stmt.BindDouble(2, EncodeDate(1483, 3, 28));
+ Stmt.BindDouble(3, EncodeDate(1520, 4, 6));
+ Stmt.StepAndReset;
+ IDs[2] := DB.LastInsertRowID;
+
+ Stmt.BindText (1, 'Arkhip Kuindzhi');
+ Stmt.BindDouble(2, EncodeDate(1842, 1, 27));
+ Stmt.BindDouble(3, EncodeDate(1898, 7, 24));
+ Stmt.StepAndReset;
+ IDs[3] := DB.LastInsertRowID;
+
+ Stmt.BindText (1, 'Nicholas Roerich');
+ Stmt.BindDouble(2, EncodeDate(1874, 10, 9));
+ Stmt.BindDouble(3, EncodeDate(1947, 12, 13));
+ Stmt.StepAndReset;
+ IDs[4] := DB.LastInsertRowID;
+
+ Stmt.BindText (1, 'Ivan Aivazovsky');
+ Stmt.BindDouble(2, EncodeDate(1817, 7, 29));
+ Stmt.BindDouble(3, EncodeDate(1900, 5, 5));
+ Stmt.StepAndReset;
+ IDs[5] := DB.LastInsertRowID;
+
+ Stmt.BindText (1, 'Ivan Shishkin');
+ Stmt.BindDouble(2, EncodeDate(1832, 1, 25));
+ Stmt.BindDouble(3, EncodeDate(1898, 3, 20));
+ Stmt.StepAndReset;
+ IDs[6] := DB.LastInsertRowID;
+ finally
+ Stmt.Free;
+ end;
+
+ // Create table "paintings"
+ DB.Execute('CREATE TABLE paintings (title TEXT, year INTEGER, artist INTEGER)');
+
+ // Fill the table with paintings info
+ Stmt := DB.Prepare('INSERT INTO paintings (title, year, artist) VALUES (?, ?, ?)');
+ try
+ // Leonardo da Vinci
+ Stmt.BindText(1, 'The Virgin and Child with St. Anne');
+ Stmt.BindInt (2, 1508);
+ Stmt.BindInt (3, IDs[1]);
+ Stmt.StepAndReset;
+
+ Stmt.BindText(1, 'Mona Lisa');
+ Stmt.BindInt (2, 1519);
+ Stmt.BindInt (3, IDs[1]);
+ Stmt.StepAndReset;
+
+ // Raphael
+ Stmt.BindText(1, 'Sistine Madonna');
+ Stmt.BindInt (2, 1514);
+ Stmt.BindInt (3, IDs[2]);
+ Stmt.StepAndReset;
+
+ Stmt.BindText(1, 'Transfiguration');
+ Stmt.BindInt (2, 1520);
+ Stmt.BindInt (3, IDs[2]);
+ Stmt.StepAndReset;
+
+ // Arkhip Kuindzhi
+ Stmt.BindText(1, 'After a rain');
+ Stmt.BindInt (2, 1879);
+ Stmt.BindInt (3, IDs[3]);
+ Stmt.StepAndReset;
+
+ Stmt.BindText(1, 'Elbrus');
+ Stmt.BindInt (2, 1895);
+ Stmt.BindInt (3, IDs[3]);
+ Stmt.StepAndReset;
+
+ // Nicholas Roerich
+ Stmt.BindText(1, 'To Kailas. Lahul');
+ Stmt.BindInt (2, 1932);
+ Stmt.BindInt (3, IDs[4]);
+ Stmt.StepAndReset;
+
+ Stmt.BindText(1, 'Krishna');
+ Stmt.BindInt (2, 1929);
+ Stmt.BindInt (3, IDs[4]);
+ Stmt.StepAndReset;
+
+ // Ivan Aivazovsky
+ Stmt.BindText(1, 'The Mary Caught in a Storm');
+ Stmt.BindInt (2, 1892);
+ Stmt.BindInt (3, IDs[5]);
+ Stmt.StepAndReset;
+
+ Stmt.BindText(1, 'Brig "Mercury" Attacked by Two Turkish Ships');
+ Stmt.BindInt (2, 1892);
+ Stmt.BindInt (3, IDs[5]);
+ Stmt.StepAndReset;
+
+ // Ivan Shishkin
+ Stmt.BindText(1, 'Morning in a Pine Forest');
+ Stmt.BindInt (2, 1889);
+ Stmt.BindInt (3, IDs[6]);
+ Stmt.StepAndReset;
+
+ Stmt.BindText(1, 'Wood Distances');
+ Stmt.BindInt (2, 1884);
+ Stmt.BindInt (3, IDs[6]);
+ Stmt.StepAndReset;
+ finally
+ Stmt.Free;
+ end;
+ finally
+ DB.Free;
+ end;
+end;
+
+procedure TForm_Main.Button_DB_ReadClick(Sender: TObject);
+var
+ DB: TSQLite3Database;
+ Stmt_Artists,
+ Stmt_Paintings: TSQLite3Statement;
+begin
+ if not FileExists('artists.db') then
+ begin
+ ShowMessage('The database does not exist. Please create one.');
+ Exit;
+ end;
+
+ DB := TSQLite3Database.Create;
+ try
+ DB.Open('artists.db');
+
+ // Show all artists and their paintings
+ Stmt_Artists := DB.Prepare('SELECT rowid, name, born, died FROM artists ORDER BY born');
+ Stmt_Paintings := DB.Prepare('SELECT title, year FROM paintings WHERE artist = ? ORDER BY year');
+ try
+ while Stmt_Artists.Step = SQLITE_ROW do
+ begin
+ Memo_Result.Lines.Add(Stmt_Artists.ColumnText(1));
+ Memo_Result.Lines.Add(DateToStr(Stmt_Artists.ColumnDouble(2)) + ' - ' + DateToStr(Stmt_Artists.ColumnDouble(3)));
+
+ Memo_Result.Lines.Add('paintings:');
+ Stmt_Paintings.BindInt(1, Stmt_Artists.ColumnInt(0));
+ while Stmt_Paintings.Step = SQLITE_ROW do
+ Memo_Result.Lines.Add(' ' + Stmt_Paintings.ColumnText(0) + ' (' + Stmt_Paintings.ColumnText(1) + ')');
+ Stmt_Paintings.Reset;
+
+ Memo_Result.Lines.Add('');
+ end;
+ finally
+ Stmt_Paintings.Free;
+ Stmt_Artists.Free;
+ end;
+ finally
+ DB.Free;
+ end;
+
+ // Add separator
+ Memo_Result.Lines.Add('------------------------------------------------');
+ Memo_Result.Lines.Add('');
+end;
+
+end.
+