TSQLite3Connection
│
English (en) │
español (es) │
français (fr) │
日本語 (ja) │
polski (pl) │
参照: チュートリアル/練習となる記事: 各種データベース |
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.
See also