With upcoming revision 1.18 of the framework, our
SynSQlite3.pas unit is able to access the SQLite3 engine
in two ways:
- Either statically linked within the project executable;
- Or from an external
sqlite3.dll library file.

The SQLite3 APIs and constants are defined in
SynSQlite3.pas, and accessible via a TSQLite3Library
class definition. It defines a global sqlite3 variable as
such:
var
sqlite3: TSQLite3Library;
To use the SQLite3 engine, an instance of
TSQLite3Library class shall be assigned to this global variable.
Then all mORMot's calls will be made through it, calling e.g.
sqlite3.open() instead of sqlite3_open().
There are two implementation classes:
| Class |
Unit |
Purpose |
TSQLite3LibraryStatic |
SynSQLite3Static.pas |
Statically linked engine (.obj within the
.exe) |
TSQLite3LibraryDynamic |
SynSQLite3.pas |
Instantiate an external sqlite3.dll instance |
Referring to SynSQLite3Static.pas in the uses
clause of your project is enough to link the .obj engine into your
executable.
Warning - breaking change: before version 1.18 of the framework,
link of static .obj was forced - so you must add a reference to
SynSQLite3Static in your project uses clause to work
as expected.
In order to use an external sqlite3.dll library, you have to
set the global sqlite3 variable as such:
FreeAndNil(sqlite3); // release any previous instance (e.g. static)
sqlite3 := TSQLite3LibraryDynamic.Create;
Of course, FreeAndNil(sqlite3) is not mandatory, and should be
necessary only to avoid any memory leak if another SQLite3 engine
instance was allocated (may be the case if SynSQLite3Static is
referred somewhere in your project's units).
Here are some benchmarks, compiled with Delphi XE3, run in a 32 bit
project, using either the static bcc-compiled engine, or an external
sqlite3.dll, compiled via
MinGW or Microsoft Visual C++.