I've been exploring SQLite within Delphi. There are several sample SQLite applications that come with Delphi if you selected to install the samples during setup. I've put together the list of SQLite samples that are available.
The common samples file path is located here:
..\Studio\20.0\Samples\Object Pascal\Database\FireDAC\Samples\
FireDAC.SQLiteIniFile Demo Sample
This sample uses FireDAC to connect to an SQLite database that emulates the structure and the operations of an INI File.
AddOn\SQLiteIniFile\Demo\SQLiteIniDemo.dproj
FireDAC.TFDLocalSQL MegaFMX Sample
The sample shows different TFDLocalSQL applications.
Comp Layer\TFDLocalSQL\MegaFMX\LSQLMega.dproj
FireDAC.SQLite Encryption Sample
This sample demonstrates how to encrypt/decrypt an SQLite database.
DBMS Specific\SQLite\Encryption\SQLite_Encrypt.dproj
Controlling Database Access Rights
The SQLite is an embedded
DBMS. This implies that it is a single user
DBMS and does not need such concepts as a user,
access rights, and so on. Still, some application can benefit from an
access right control, for example:
- An application can restrict rights depending on an end-user license. A demo license means less possibilities, a full license provides all possibilities.
- Multi-tier data access frameworks can use their own user concept and control data access rights using some generic approach.
Again, SQLite provides a unique feature allowing you to authorize or not
SQL commands. To work with this
API, a Delphi application should set the OnAutorize event handler of the TSQLiteDatabase object, which is a database connection wrapping object. Hook this event after a database connection is opened.
DBMS Specific\SQLite\OnAuthorize\SQLite_OnAuthorize.dpr oj
Hooking Database Updates
SQLite provides an unique
API allowing you to monitor all updates to a database. This feature can be used, for example, to log all updates to a
DB. To work with this
API, a Delphi application should set the OnUpdate event handler of the TSQLiteDatabase object, which is a database connection wrapping object. Hook this event after a database connection is opened.
DBMS Specific\SQLite\OnUpdate\SQLite_OnUpdate.dproj
Custom Collations
SQLite stores and handles all character data either in UTF8 or UTF16, depending on the OpenMode connection parameter. When SQLite needs to compare or sort a character data, it has to know what rules to use for this. The rules are known as a collation.
DBMS Specific\SQLite\UserCollation\SQLite_UserColl.dpro j
Custom Functions
SQLite does not support the stored procedure or function concept, as it allows you to use the host language environment to extend the engine functionality. SQLite allows you to register host language functions in the SQLite engine and use them in the
SQL commands. FireDAC simplifies this by introducing the TFDSQLiteFunction component.
DBMS Specific\SQLite\UserFunc\SQLite_UserFunc.dproj
The SQLite R*Tree Module
An R-Tree is a special index that is designed for doing range queries. R-Trees are most commonly used in geospatial systems where each entry is a rectangle with minimum and maximum X and Y coordinates. Given a
query rectangle, an R-Tree is able to quickly find all entries that are contained within the
query rectangle or which overlap the
query rectangle.
This idea is easily extended to three dimensions for use in CAD systems. R-Trees also find use in time-domain range look-ups. For example, suppose a database records the starting and ending times for a large number of events. A R-Tree is able to quickly find all events that were active at any time during a given time interval, or all events that started during a particular time interval, or all events that both started and ended within a given time interval. And so forth.
DBMS Specific\SQLite\UserRTree\SQLite_UserRTree.dproj
Title: SQLite
Brief Description: This snippet shows you how to populate a listbox from a SQLite database using FireDAC and LiveBindings. See the section called "Accessing a Database" in the Mobile Tuturials topic in the documentation for more information and licensing requirements.
Platforms supported: iOS, Android
..\Mobile Snippets\FireDACSQLite\FireDAC_SQLite.dproj
Enjoy
Semper Fi,
Gunny Mike
Weiterlesen...