# TSQLite3Connection

English (en) français (fr) 日本語 (ja)

 Database portal References: Tutorials/practical articles: Databases Advantage - MySQL - MSSQL - Postgres - Interbase - Firebird - Oracle - ODBC - Paradox - SQLite - dBASE - MS Access - Zeos

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.

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.