I've done quite a bit with several relational database managers.
And come away not entirely happy.
In September 2026, I came across SQLite for the first time, and... for the right jobs... it looks like a winner to me.
The link in the previous paragraph will take you to the project's home. It opens with the following text...
"SQLite is a C-language library that implements a small, fast, self-contained, high-reliability, full-featured, SQL database engine. SQLite is the most used database engine in the world. SQLite is built into all mobile phones and most computers and comes bundled inside countless other applications that people use every day."
Pretty impressive! And from my early experiments with it, I am inclined to believe all of that.
It is gloriously simple, clean, elegant.
Open source. Free. Multi-platform.
For Windows, "installing" it is only a matter of creating a folder and putting some files from two downloaded .zips into it.
That gives you the basic SQLite "engine".
Although you can interact with it via a terminal program, or scripts, you'd be well advised to install the "DB Browser for SQLite". That gives you a GUI for using the database manager to create databases, specify the tables in your databases, specify the "columns" in the tables, and populate the "rows", (aka "fields" and "records"). You can get DB Browser for SQLite complied for various environments from sqlitebrowser.org/dl/. Under Windows, the website gives you an .msi, and launching that takes you through a simple install routine. (I'd encourage you to install both "flavors" of the browser. Both "DB Browser (SQLite)" and "DB Browser (SQLCipher)".
This is called SQLlite for a reason! It is not a replacement for, say the database manager supplied with Libre Office. but it will do things that I wanted to do... with only a small footprint.
I wanted to build a small system to log some data. I sleep poorly, and I wanted to create a way to note when I awoke in the night, when I had to get up to pee, etc.
I haven't replaced any of the Fitbit type monitors... but I've built something that only uses an old, unloved laptop, and gives me what I want. The laptop sits on the bedside table. It has an app that has a dark red back-ground, so I stay half asleep as I click a button for "woke up" or "went to pee", or one or two other things.
I just click the right button... and my Lazarus program, using the SQLite engine, makes an entry in a table to say which of several different events I was reporting, and (automatically) adds the date and time of the event to a second field in the table.
I'll try to get that program written up, too. But for now...
This code is VERY SIMPLE. It is without frills. So you can see the heart of how you would read data from a SQLite database table.
It is Bad Code in that it is very inflexible. (I can write "better" code by the way. But if I added the code to allow the user to choose the database he/she wanted to read from, to allow the user to say which table, which fields, that would add code to what is below, and make it harder to see the core elements... wouldn't it?
I'll tell you how to fetch a zip with the whole project in a moment. Note that it expects to fine a database called "". It expects to find a table called "events", with a field called "event". I've included it in the .zip... but even then, you aren't out of the woods.
It won't run for you as it stands. You'll need to tweak the line that starts "dbase='C:\Users\lapto\Documents\Databases..." witgh the path to where you've put the database. (and include the database's name.) If it is in the same directory as the .exe, then you can use a simple "dbase='[[DATABASE's NAME']]"
unit ldn126read_sqlite_tableU1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, SQLite3Conn, SQLDB;//These two added when the SQL objects added. //Don't worry... they are available after an ordinary install] //of the IDE. (For version 4.6, anyway!) const vers='25 Sep 26'; //started 25 Sep 26... my second day of using SQLite! dbase='C:\Users\lapto\Documents\Databases\SQLite\Sqlite-1st-made on 24 Sep 26\FirstSqliteDB24Sept26-events.db'; type { Tldn126f1 } Tldn126f1 = class(TForm) Conn: TSQLite3Connection; Query: TSQLQuery; Trans: TSQLTransaction; buQuit: TButton; buDoIt: TButton; Memo1: TMemo; procedure buDoItClick(Sender: TObject); procedure buQuitClick(Sender: TObject); procedure FormCreate(Sender: TObject); private public end; var ldn126f1: Tldn126f1; implementation {$R *.lfm} { Tldn126f1 } procedure Tldn126f1.buQuitClick(Sender: TObject); begin close;//is app...terminate better? end; procedure Tldn126f1.buDoItClick(Sender: TObject); begin Memo1.lines.clear; // 1. Configure query Query.Database := Conn; Query.SQL.Text := 'SELECT * FROM events'; // Replace 'events' with your table's name // 2. Execute and read Conn.Connected := True; Trans.Active := True; Query.Open; // 3. Iterate through records while not Query.Eof do begin Memo1.lines.add(Query.FieldByName('event').AsString+ ' // '+ Query.FieldByName('datetimeofevent').AsString);//Replace 'event' and 'datetimeofevent' with the names of columns in your database // Access fields by name or index // ShowMessage(Query.FieldByName('datetimeofevent').AsString+ // 'xxx');//Replace 'event' and 'datetimeofevent' with the names of columns in your database // Move to next record Query.Next; end; //finally // 4. Cleanup Query.Close; Conn.Connected := False; Query.Free; Trans.Free; Conn.Free; end;//DoIt procedure Tldn126f1.FormCreate(Sender: TObject); begin Conn.DatabaseName:=dbase; Trans.DataBase:=Conn; Conn.Transaction:=Trans; Query:=TSQLQuery.Create(nil); end;//FormCreate end.
By the way: Most of that code was written for me, 1st attempt, by the Claude AI. (Free model.) And the syntax highlighting of the above was courtesy of hilite.me, using the Delphi rules.
The only "trick" to writing something like the above from scratch is how you give your project the followoing objects...
Good news: What you need is already present in an ordinary Lazarus IDE installation! (I was using version 4.6, in September 2026, on a Windows 11 machine.)
Go to the "SQLdb" tab of the components palette.
There's a dull blue feather there, which the pop-up tells us is for "TSQLite3Connection".
Put one on your form. (It is an "invisible" object... nothing will show on the form when the code runs. (Like the SaveDialog or Timer objects.)
Your code should now have...
SQLite3Connection1: TSQLite3Connection;
... in it. *Use the Object Inspector to change the name of your TSQLite3Connection object to "Conn" (Short for Connector.) (Do not just edit the text in the .pas file.)
(It would work, if you didn't change the name... but you'd get tired of typing the IDE-generated name for the object.)
This takes care of some of what the Leo answer said we'd need to do. We have made a start on...
// 1. Create components. TSQLite3Connection1:= TSQLite3Connection.Create(nil);
... the easy IDE+GUI way!
Still using the "SQLdb" tab of the components palette, add a TSQLTransaction object, and again, rename it (with the Object Inspector) to "Trans", for Transaction. The icon for the TSQLTransaction object is a multi-platter disk, the letters "TXT" and a lightning bolt.
And add a TSQLQuery object, rename it "Query".
You can download a .zip file (LDN qEditit .zip) with the example of...qEditit. It has all the sourcecode, and a copy of the compiled .exe, as well, so you can have a play with that even before you bother to fire up your Lazarus.
Search across my sites with a Google search...
This searches wywtk, skywoof, sheepdogguides, sheepdogsoftware and arunet... but doesn't always give all of the pages that have content which matches the criterion.
Use the following to search THIS site.... (Go to my other sites, below, and use their search buttons if you want to search them.)
(Alas... my Lazarus material is split across two sites... SheepdogGuides.com and WYWTK.com. Sorry!)
This search engine is "old skool"- it merely looks for the words you type, so....
* Spell them properly.
* Don't bother with "How do I get rich?" That will merely return pages with "how", "do", "I"....
Please also note that I have four other sites, and that this search will not include them. They have their own search buttons.
My WhatYouWantToKnow site- https:/wywtk.com.
My SheepdogSoftware.co.uk site.
https://www.arunet.co.uk/tkboyd/index2.htm: My ancient site at Arunet. (Some of the material there is dated, but there are useful pages about general principles which are timeless.) There's a section devoted to programming.
To email this page's editor, Tom Boyd.... Editor's email address. Suggestions welcomed! Please cite "sl-read-data.htm".
Page has been tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org. It passes in some important ways, but still needs work to fully meet HTML 5 expectations. (Copy your page's URL to your clipboard before clicking on the icon, so you can easily paste it into the validator when it has loaded.)-->
AND it has been tested with...
Why is there a script or hidden graphic on this page? I have my web-traffic monitored for me by eXTReMe tracker. They offer a free tracker. If you want to try one, check out their site. Neither my webpages nor my programs incorporate spyware, but if the page has Google tools, they also involve scripts. Why do I mention the scripts? Be sure you know all you need to about spyware.
-- Page ends --