Sign in Join
Wiki copytemporary

TSQLite3Connection

English · Español · Français · Polski · 日本語

Note: Instead of using a TSQLite3Connection a proxy-like TSQLConnector may be used to create more generic database applications

TSQLite3Connection is the database connection component for use SQLite. The component is found on SQLdb tab of the Component Palette.

TSQLite3connection is a FCL (not LCL) non visual component meaning that it can be used in (eg) ObjectPascal, console applications as well as Lazarus GUI ones. Unfortunately there are no FCL docs for TSQLite3Connection but its interface is similar to its parent ( TSQLConnection ). As SQLite is an embedded or non-server database, its use may not require setting .host, .username nor .password. An example of how its used in an ObjectPascal programme is below, when used in Lazarus, similar setting can be made using the Object Inspector.

pascal
program BasicDBase;
{$mode objfpc} {$ifdef mswindows}{$apptype console}{$endif}
uses
  sqldb, sqlite3conn;
var
    Connect : TSQLite3Connection;
    Trans : TSQLTransaction;

begin
    Connect := TSQLite3Connection.Create(nil);
    Trans := TSQLTransaction.Create(Connect);
    Connect.Transaction := Trans;
    Connect.DatabaseName := 'test_dbase';
    Trans.StartTransaction;  // opens Connect, EInOutError if SQLite not installed
    Connect.ExecuteDirect('create table TBLNAMES (ID integer Primary Key, NAME varchar(40));');
    Trans.Commit;
    Trans.Free;
    Connect.Free;
end.

The ExecuteDirect() procedure is a fairly limited means to call SQL, in a real ap, you will need something like TSQLQuery. Note also the above demo does not do any error checking.

See also


From the Free Pascal wiki, page "TSQLite3Connection", as it stood on 2020-03-01 after a change by Bart, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.