Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
DatabaseRAD Studio

Newcomer’s Perspective – FireDAC and SQLite

FireDAC Universal Database Connectivity

FireDAC is Embarcadero’s library for universal data access – connection to just about any database protocol you can find. It abstracts the protocol-level details and presents a common interface so developers can build their applications to be database agnostic and flexible in the event of future design changes.

My work this week focused on FireDAC and local databases. SQLite is straightforward but FireDAC challenged me because, despite the many resources available, I couldn’t figure out how to get the initial connection set up without tutoring from @JimMcKeeth. Once demonstrated, the solution seemed simple and clarified my original problem as a low comprehension of FireDAC component relationships. As a visual learner, I needed a picture and couldn’t find one. My goal this week is to fill that visual gap for the new FireDAC developer.

Simple local database setup with FireDAC
<em>Figure 1 Simple local database setup with FireDAC<em>

As depicted, the three components needed to connect to a database are an FDConnection, an FDQuery or similar Query class, and a DataSource. The FDConnection handles the protocol of connecting to your database of choice, the FDQuery executes commands to request/modify data within the connected database, and the DataSource makes the information available to other components like a DBGrid. They connect in sequence: TDataSource to FDQuery to FDConnection. Once linked and the Connected/Active boxes are checked without an error message appearing, you can test the database by double-clicking the FDQuery, entering a command, and selecting “Execute”.

A word of warning – FireDAC won’t work with SQLite unless the correct DLL files are installed. Per the DocWiki instructions, download and extract the x64 sqlite3.dll to C:\Windows\System32 and the x86 sqlite3.dll to C:\Windows\SysWOW64. I didn’t follow all the configuration steps and it resulted in a "Socket Error: Connection Closed" until the DLLs were in place.

Links to the mentioned resources:

P.S. If you know SEO, help me get this image into search engine results!

See What's New in 12.2 Athens See What's New in 12.2 Athens Dev Days of Summer 2-24

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES