Difference between revisions of "TSQLite3Connection/ja"

From Lazarus wiki
Jump to navigationJump to search
(Created page with "{{TSQLite3Connection/ja}} {{Infobox databases/ja}} {{Note|Instead of using a TMySQLite3Connection a proxy-like TSQLConnector may be used to create more generic database a...")
 
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{TSQLite3Connection/ja}}
+
{{TSQLite3Connection}}
 
{{Infobox databases/ja}}
 
{{Infobox databases/ja}}
  
{{Note|Instead of using a TMySQLite3Connection a proxy-like [[TSQLConnector]] may be used to create more generic database applications}}'''TSQLite3Connection''' [[image:tsqlite3connection.png]] is the database connection component for use [[SQLite]]. The component is found on [[SQLdb tab]] of the [[Component Palette]].
+
{{Note| TSQLite3Connection を使う代わりに、プロキシライクな [[TSQLConnector/ja]] を使うことで、より一般的なデータベースアプリケーションを作ることができます。}}'''TSQLite3Connection''' [[image:tsqlite3connection-n.png]] [[SQLite/ja]]を使うためのデータベース接続コンポーネントです。これらのコンポーネントは、[[Component Palette/ja]] [[SQLdb tab/ja]] にあります。
  
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
+
TSQLite3connection FCL (LCLではなく) の 非ビジュアルコンポーネントであり、Lazarus の GUI と同様に、(例えば) ObjectPascal やコンソールアプリケーションに用いることができます。残念ながら TSQLite3Connection についての FCL ドキュメントはありません。しかし、そのインターフェイスは親クラスの( [[TSQLConnection/ja]] )とほぼ同じです。SQLite は組み込みのまたは非サーバー型のデータベースであるので、
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
+
その利用にあたっては、.host .username、また .password の設定は不要です。サンプルとして、ObjectPascal のプログラムではどのように利用するかを以下に示します。
Lazarus, similar setting can be made using the Object Inspector.
+
Lazarus GUI より用いる場合は、同様な設定を オブジェクトインスペクターから行えます。
  
<syntaxhighlight>
+
(訳注;以下を実行する前に SQLite をインストールする必要がありますが、その際に、Lazarus と同じcpu向け(つまり、32bit(x86)用か64bit用か) のSQLiteを用いる必要があります。※たぶん)
 +
(訳注;2度目の実行時には、「TBLNAMESのテーブルは作成済み」というエラーメッセージが表示されると思います。)
 +
 
 +
<syntaxhighlight lang=pascal>
 
program BasicDBase;
 
program BasicDBase;
 
{$mode objfpc} {$ifdef mswindows}{$apptype console}{$endif}
 
{$mode objfpc} {$ifdef mswindows}{$apptype console}{$endif}
Line 22: Line 25:
 
     Connect.Transaction := Trans;
 
     Connect.Transaction := Trans;
 
     Connect.DatabaseName := 'test_dbase';
 
     Connect.DatabaseName := 'test_dbase';
     Trans.StartTransaction;  // opens Connect, EInOutError if SQLite not installed
+
     Trans.StartTransaction;  // データベースへの接続を行います。SQLite をインストールしていない場合、EInOutError が起きます。
 
     Connect.ExecuteDirect('create table TBLNAMES (ID integer Primary Key, NAME varchar(40));');
 
     Connect.ExecuteDirect('create table TBLNAMES (ID integer Primary Key, NAME varchar(40));');
 
     Trans.Commit;
 
     Trans.Commit;
Line 31: Line 34:
  
  
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
+
ExecuteDirect() プロシージャは SQLコールに対して限定的なものであるため、実際のアプリケーションでは、おそらく TSQLQuery のようなものが必要となるでしょう。
any error checking.   
+
また、上記デモはエラーチェックをしていないことを念頭においてください。
  
==See also==
+
==関連情報==
 
* [[TSQLConnector/ja]]
 
* [[TSQLConnector/ja]]
 
* [[SQLite/ja]]
 
* [[SQLite/ja]]
  
{{LCL Components}}
+
{{LCL Components/ja}}

Latest revision as of 07:47, 31 March 2024

English (en) español (es) français (fr) 日本語 (ja) polski (pl)

データベースのポータル

参照:

チュートリアル/練習となる記事:

各種データベース

Advantage - MySQL - MSSQL - Postgres - Interbase - Firebird - Oracle - ODBC - Paradox - SQLite - dBASE - MS Access - Zeos
Light bulb  Note: TSQLite3Connection を使う代わりに、プロキシライクな TSQLConnector/ja を使うことで、より一般的なデータベースアプリケーションを作ることができます。

TSQLite3Connection tsqlite3connection-n.pngSQLite/jaを使うためのデータベース接続コンポーネントです。これらのコンポーネントは、Component Palette/jaSQLdb tab/ja にあります。

TSQLite3connection は FCL (LCLではなく) の 非ビジュアルコンポーネントであり、Lazarus の GUI と同様に、(例えば) ObjectPascal やコンソールアプリケーションに用いることができます。残念ながら TSQLite3Connection についての FCL ドキュメントはありません。しかし、そのインターフェイスは親クラスの( TSQLConnection/ja )とほぼ同じです。SQLite は組み込みのまたは非サーバー型のデータベースであるので、 その利用にあたっては、.host や .username、また .password の設定は不要です。サンプルとして、ObjectPascal のプログラムではどのように利用するかを以下に示します。 Lazarus GUI より用いる場合は、同様な設定を オブジェクトインスペクターから行えます。

(訳注;以下を実行する前に SQLite をインストールする必要がありますが、その際に、Lazarus と同じcpu向け(つまり、32bit(x86)用か64bit用か) のSQLiteを用いる必要があります。※たぶん) (訳注;2度目の実行時には、「TBLNAMESのテーブルは作成済み」というエラーメッセージが表示されると思います。)

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;  // データベースへの接続を行います。SQLite をインストールしていない場合、EInOutError が起きます。
    Connect.ExecuteDirect('create table TBLNAMES (ID integer Primary Key, NAME varchar(40));');
    Trans.Commit;
    Trans.Free;
    Connect.Free;
end.


ExecuteDirect() プロシージャは SQLコールに対して限定的なものであるため、実際のアプリケーションでは、おそらく TSQLQuery のようなものが必要となるでしょう。 また、上記デモはエラーチェックをしていないことを念頭においてください。

関連情報


LCL Components
Component Tab Components
Standard TMainMenu • TPopupMenu • TButton • TLabel • TEdit • TMemo • TToggleBox • TCheckBox • TRadioButton • TListBox • TComboBox • TScrollBar • TGroupBox • TRadioGroup • TCheckGroup • TPanel • TFrame • TActionList
Additional TBitBtn/ja • TSpeedButton/ja • TStaticText/ja • TImage/ja • TShape/ja • TBevel/ja • TPaintBox/ja • TNotebook/ja • TLabeledEdit/ja • TSplitter/ja • TTrayIcon/ja • TControlBar/ja • TFlowPanel/ja • TMaskEdit/ja • TCheckListBox/ja • TScrollBox/ja • TApplicationProperties/ja • TStringGrid/ja • TDrawGrid/ja • TPairSplitter/ja • TColorBox/ja • TColorListBox/ja • TValueListEditor/ja
Common Controls TTrackBar • TProgressBar • TTreeView • TListView • TStatusBar • TToolBar • TCoolBar • TUpDown • TPageControl • TTabControl • THeaderControl • TImageList • TPopupNotifier • TDateTimePicker
Dialogs TOpenDialog • TSaveDialog • TSelectDirectoryDialog • TColorDialog • TFontDialog • TFindDialog • TReplaceDialog • TTaskDialog • TOpenPictureDialog • TSavePictureDialog • TCalendarDialog • TCalculatorDialog • TPrinterSetupDialog • TPrintDialog • TPageSetupDialog
Data Controls TDBNavigator/ja • TDBText/ja • TDBEdit/ja • TDBMemo/ja • TDBImage/ja • TDBListBox/ja • TDBLookupListBox/ja • TDBComboBox/ja • TDBLookupComboBox/ja • TDBCheckBox/ja • TDBRadioGroup/ja • TDBCalendar/ja • TDBGroupBox/ja • TDBGrid/ja • TDBDateTimePicker/ja
Data Access TDataSource/ja • TCSVDataSet/ja • TSdfDataSet/ja • TBufDataset/ja • TFixedFormatDataSet/ja • TDbf/ja • TMemDataset/ja
System TTimer • TIdleTimer • TLazComponentQueue • THTMLHelpDatabase • THTMLBrowserHelpViewer • TAsyncProcess • TProcessUTF8 • TProcess • TSimpleIPCClient • TSimpleIPCServer • TXMLConfig • TEventLog • TServiceManager • TCHMHelpDatabase • TLHelpConnector
Misc TColorButton • TSpinEdit • TFloatSpinEdit • TArrow • TCalendar • TEditButton • TFileNameEdit • TDirectoryEdit • TDateEdit • TTimeEdit • TCalcEdit • TFileListBox • TFilterComboBox • TComboBoxEx • TCheckComboBox • TButtonPanel • TShellTreeView • TShellListView • TXMLPropStorage • TINIPropStorage • TJSONPropStorage • TIDEDialogLayoutStorage • TMRUManager • TStrHolder
LazControls TCheckBoxThemed • TDividerBevel • TExtendedNotebook • TListFilterEdit • TListViewFilterEdit • TLvlGraphControl • TShortPathEdit • TSpinEditEx • TFloatSpinEditEx • TTreeFilterEdit • TExtendedTabControl •
RTTI TTIEdit • TTIComboBox • TTIButton • TTICheckBox • TTILabel • TTIGroupBox • TTIRadioGroup • TTICheckGroup • TTICheckListBox • TTIListBox • TTIMemo • TTICalendar • TTIImage • TTIFloatSpinEdit • TTISpinEdit • TTITrackBar • TTIProgressBar • TTIMaskEdit • TTIColorButton • TMultiPropertyLink • TTIPropertyGrid • TTIGrid
SQLdb TSQLQuery/ja • TSQLTransaction/ja • TSQLScript • TSQLConnector • TMSSQLConnection • TSybaseConnection • TPQConnection • TPQTEventMonitor • TOracleConnection • TODBCConnection • TMySQL40Connection • TMySQL41Connection • TMySQL50Connection • TMySQL51Connection • TMySQL55Connection • TMySQL56Connection • TMySQL57Connection • TSQLite3Connection/ja • TIBConnection • TFBAdmin • TFBEventMonitor • TSQLDBLibraryLoader
Pascal Script TPSScript • TPSScriptDebugger • TPSDllPlugin • TPSImport_Classes • TPSImport_DateUtils • TPSImport_ComObj • TPSImport_DB • TPSImport_Forms • TPSImport_Controls • TPSImport_StdCtrls • TPSCustomPlugin
SynEdit TSynEdit • TSynCompletion • TSynAutoComplete • TSynMacroRecorder • TSynExporterHTML • TSynPluginSyncroEdit • TSynPasSyn • TSynFreePascalSyn • TSynCppSyn • TSynJavaSyn • TSynPerlSyn • TSynHTMLSyn • TSynXMLSyn • TSynLFMSyn • TSynDiffSyn • TSynUNIXShellScriptSyn • TSynCssSyn • TSynPHPSyn • TSynTeXSyn • TSynSQLSyn • TSynPythonSyn • TSynVBSyn • TSynAnySyn • TSynMultiSyn • TSynBatSyn • TSynIniSyn • TSynPoSyn
Chart TChart • TListChartSource • TRandomChartSource • TUserDefinedChartSource • TCalculatedChartSource • TDbChartSource • TChartToolset • TChartAxisTransformations • TChartStyles • TChartLegendPanel • TChartNavScrollBar • TChartNavPanel • TIntervalChartSource • TDateTimeIntervalChartSource • TChartListBox • TChartExtentLink • TChartImageList
IPro TIpFileDataProvider • TIpHtmlDataProvider • TIpHttpDataProvider • TIpHtmlPanel
Virtual Controls TVirtualDrawTree • TVirtualStringTree • TVTHeaderPopupMenu