Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

Quickly Learn How To Connect And Manage A SQLite Database For Delphi/C++ Builder With SQLite Sample App

SQLite becomes popular for working with light weight embedded, mobile, IoT, and desktop applications. Do you want your Delphi and C++ Builder Applications to connect with SQLite Database? How to start? Don’t worry, FireDAC offers robust components to connect with MySQL Database.

FireDAC.SQLLite Sample app demonstrates how to use FireDAC to work with SQLite Database.

You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.

Components used in the Sample App:

Implementation Details:

The simplest to configure connection to SQLite database at run-time is to build a temporary connection definition: In the sample, the temporary definition is created when the <Open database…> item is selected in the Connection combo box. Open the following database: C:\Users\Public\Documents\Embarcadero\Studio\21.0\Samples\data\FDDemo.sdb.

In the demo database, the Categories and Products tables have one-to-many relation by CategoryID field. Mention the query to the qryCategories.SQL property and qryProducts.SQL property.

Finally, the qryProducts.MasterSource property is set to dsCategories, while the MasterFields property is set to CategoryID. This creates a master-details relationship between the datasets. StockPrice function is a custom function defined using the TFDSQLiteFunction component. The calculation is configured using a OnCalculate event:The event occurs when fetching records from the database. It returns the calculated value.Simple queries execution is demonstrated via ExecSQL method of TFDConnection.

Managing the SQLite Database : The sample also shows how to perform several Management of databases such as:

All this Management of databases is done using the following components: TFDSQLiteBackupTFDSQLiteSecurityTFDSQLiteValidateTFDSQLiteCollation and TFDSQLiteFunction.

This demo demonstrates managing database encryption, validating database and creating database backup: Check out the full article in the DocWiki about the FireDAC SQLite Sample.

<strong>SQLite Sample App<strong>

Check out the full source code for the FireDAC.SQLLite projects for Delphi and C++Builder over on GitHub.

Exit mobile version