Embarcadero has made available a new FireDAC driver for the SQLite Encryption Extension (SEE) database. The download is in GetIt and here are some details behind this decision.
RAD Studio 11 Alexandria, like previous versions, ships with a FireDAC driver for the SQLite database offering two different approaches for delivery. One option is static linking, that is, to compile SQLite into your application binary, by linking the compiled code. The second option is dynamic linking, that is, to use an external SQLite DLL. The two alternatives and their configurations for different platforms are covered in details at:
FireDAC SQLite Encryption
The static linking version of FireDAC SQLite driver offers database encryption support, using a database hook mechanism (SQLITE_HAS_CODEC) that has now been removed from the latest versions of SQLite by the database dev team. For this reason FireDAC still supports SQLite encryption on the last version of SQLite with the “feature”. If you want the latest SQLite and don’t need encryption, you can use the DLL version.
Going forward the plan is to deprecate FireDAC SQLite Encryption or at least to provide it as a legacy option, and move to the latest version of SQLite also for the statically compiled version. Notice also that if you from FireDAC SQLite Encryption to FireDAC SQLite Encryption Extension (SEE) driver, you’ll end up with a different encryption implementation: For this reason the SQLite database files won’t be compatible.
SQLite Encryption Extension (SEE)
The path forward with SQLite Encryption by Hwaci (the company behind SQLite) is to recommend the use of SQLite Encryption Extension (SEE), a paid version of SQLite. You can read more about this database at these links:
- The SQLite SEE wiki has overall documentation
- The SQLite SEE Software License Agreement (or EULA)
- The SQLite SEE price and purchase information
Given this was requested by some customers to support SQLite EE, Embarcadero has created a specific FireDAC driver. Notice that the license agreement indicates you should use static linking (but, because I’m not a lawyer, refer to the license linked above for details). No third party like Embarcadero is entitled to distribute the library source or the compiled binary code. So what Embarcadero is providing to developers is the source code of the new FireDAC driver, plus some C++Builder-based scripts to compile the library. You’ll have to build and link the two pieces (library code and Delphi unit) together on your development system — and this might require owning the full RAD Studio, as you need to compile both C++ and Delphi code.
Consider InterBase ToGo as an Alternative
Before I get to the download and practical side, notice that, depending on your target platforms and other requirements, you can consider using InterBase ToGo and its database encryption support as an alternative to SQLite EE — the price model is a bit different, which makes it hard to compare directly, but I’m certain Embarcadero sales team can help you figure out.
The Driver GetIt Download
As mentioned, the download is available in a specific, new GetIt package for customers with an active update subscription:
Embarcadero will make the download available also in the customers portal shortly. Below, I’ve attached the read me of this GetIt package with additional information.
FireDAC SQLite SEE Driver Read Me File
This is the complete text of the readme file in the package:
FireDAC SQLite SEE static API wrapping classes, Copyright 2021 Embarcadero Technologies. All rights reserved.
Usage is subject to RAD Studio 11 EULA, see https://www.embarcadero.com/products/rad-studio/rad-studio-eula
SQLite Encryption Extension (SEE) is a product by Hipp, Wyrick & Company, Inc. (Hwaci) and it is subject to
the license available at https://www.hwaci.com/sw/sqlite/license-see.html
=== Static linkage
This is recommended way to use SQLite SEE with your application. Use the new unit FireDAC.Phys.SQLiteWrapper.SEEStat.pas.
It enables static linkage of sqlite3 SEE to an application. This unit is provided to the customers only as PAS file, because
to produce DCU / etc we need sqlite3.obj, which is subject to SQLite SEE license restriction.
* Set FDPhysSQLiteDriverLink.Linkage=slSEEStatic. This will automatically add FireDAC.Phys.SQLiteWrapper.SEEStat to “uses” clause
* … or include FireDAC.Phys.SQLiteWrapper.SEEStat instead of FireDAC.Phys.SQLiteWrapper.Stat into application uses clause
* Make FireDAC.Phys.SQLiteWrapper.SEEStat.pas accessible to compiler
* Compile sqlite3 SEE and produce sqlite3_x86.obj / sqlite3_x64.obj. See “Recompiling SQLite SEE” section below
* Put sqlite3_x86.obj / sqlite3_x64.obj into the folder with FireDAC.Phys.SQLiteWrapper.SEEStat.pas
=== Dynamic linkage
This is subject to redistribution restrictions (see Hwaci license)
* Set FDPhysSQLiteDriverLink.Linkage=slDynamic
* Set FDPhysSQLiteDriverLink.SEEKey=’xxx’, where ‘xxx’ is SEE activation key
You can read more details in “wwwreadme.wiki” SEE distribution file, chapter “5.0 C Interface”
* Provide sqlite3.dll SEE version and make it accessible to FireDAC application
=== What works, what does not
FireDAC SQLite encryption (FSE) supports features, which SQLite SEE does not support:
* when wrong password is specified, then FSE will return “wrong password”, SEE always returns “file is not a database”
* FSE can return the current encryption algorithm, SEE cannot
* the list of possible values for “Encrypt” FireDAC connection definition parameter has FSE supported values, not SEE ones
Notice that existing databases build with FireDAC SQLite encryption are not compatible with SQLite SEE databases.
When you will build your application, it will be good to first get FireDAC environment reports, to be sure that “the correct SQLite” is used.
=== Recompiling SQLite SEE
Use provided sqlite_compile.bat to produce sqlite3_x86.obj / sqlite3_x64.obj. Before running sqlite_compile.bat update it and set these variables to your actual values:
* BDS – RAD Studio installation folder
* SQLITE_SRC – path to sqlite source file