Difference between revisions of "Lazarus Database Overview/ja"

From Lazarus wiki
Jump to navigationJump to search
Line 6: Line 6:
 
この記事は、 Lazarus で動くデータベースに関する概要です。
 
この記事は、 Lazarus で動くデータベースに関する概要です。
  
Lazarus はいくつかのデータベースをsupports several databases out of the box (using e.g. the SQLDB framework), しかしながら、the developer must install the required packages (client libraries) for each one.  
+
Lazarus はいくつかのデータベースをインストール時にサポートしています。 (using e.g. SQLDB フレームワークを用いて), しかし、プログラム作成者は必要に応じてthe developer must install the required packages (client libraries) for each one.  
  
 
You can access the database through code or by dropping components on a form. The data-aware components represent fields and are connected by setting the DataSource property to point to a [[TDataSource]]. The Datasource represents a table and is connected to the database components (examples: ''[[TPSQLDatabase]]'', ''[[TSQLiteDataSet]]'') by setting the DataSet property. The data-aware components are located on the [[Data Controls tab]]. The Datasource and the database controls are located on the "Data Access" tab.
 
You can access the database through code or by dropping components on a form. The data-aware components represent fields and are connected by setting the DataSource property to point to a [[TDataSource]]. The Datasource represents a table and is connected to the database components (examples: ''[[TPSQLDatabase]]'', ''[[TSQLiteDataSet]]'') by setting the DataSet property. The data-aware components are located on the [[Data Controls tab]]. The Datasource and the database controls are located on the "Data Access" tab.
Line 60: Line 60:
 
# [[Zeos]]. Use component '''TZConnection''' with protocol 'postgresql' from palette '''Zeos Access'''
 
# [[Zeos]]. Use component '''TZConnection''' with protocol 'postgresql' from palette '''Zeos Access'''
 
# [https://www.devart.com/pgdac/ PostgreSQL data access Lazarus component]
 
# [https://www.devart.com/pgdac/ PostgreSQL data access Lazarus component]
 
 
== PostgreSQL ==
 
 
PostgreSQLデータベースサーバへ接続するには、TPQConnectionコンポーネントを使います。
 
このコンポーネントはPostgreSQLのlibpqコネクションライブラリを利用しています。
 
[http://www.postgresql.org/docs/8.0/interactive/libpq.html],
 
ですから、簡単にほとんどの(訳注:バージョンの?)PostgreSQLデータベースに接続できます。
 
しかし、このコンポーネントは、下記の接続オプションはサポートしていません。
 
 
* Port
 
* ClientEncoding
 
 
このほかにも、接続していないパラメータがある可能性があります。
 
  
 
== Lazarus と SQLite ==
 
== Lazarus と SQLite ==

Revision as of 16:46, 9 June 2017

English (en) español (es) français (fr) 日本語 (ja) polski (pl) русский (ru)

データベースのポータル

参照:

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

各種データベース

Advantage - MySQL - MSSQL - Postgres - Interbase - Firebird - Oracle - ODBC - Paradox - SQLite - dBASE - MS Access - Zeos

概要

この記事は、 Lazarus で動くデータベースに関する概要です。

Lazarus はいくつかのデータベースをインストール時にサポートしています。 (using e.g. SQLDB フレームワークを用いて), しかし、プログラム作成者は必要に応じてthe developer must install the required packages (client libraries) for each one.

You can access the database through code or by dropping components on a form. The data-aware components represent fields and are connected by setting the DataSource property to point to a TDataSource. The Datasource represents a table and is connected to the database components (examples: TPSQLDatabase, TSQLiteDataSet) by setting the DataSet property. The data-aware components are located on the Data Controls tab. The Datasource and the database controls are located on the "Data Access" tab.

See the tutorials for Lazarus/FPC built in database access, suitable for Firebird, MySQL, SQLite, PostgreSQL etc:

Lazarus と Interbase / Firebird

  • Firebird is very well supported out of the box by FPC/Lazarus (using SQLDB); please see Firebird for details.
  • Other Firebird libraries/ja has a list of alternative access libraries (e.g. PDO, Zeos, FBlib)

Lazarus と MySQL

  • Please see mysql/ja for details on various access methods, which include:
  1. ビルトインの SQLdb によるサポート
  2. PDO(Pascal Data Objects)
  3. Zeos
  4. MySQL data access Lazarus components

Lazarus と MSSQL/Sybase

Microsoft SQL Server データベースには、以下の方法で接続できます。

  1. SQL Server data access Lazarus components。 これらは Windows と Mac OS X 上で動きます。ダウンロードは自由にできます。
  2. ビルトインの SQLdb コネクタである TMSSQLConnectionTSybaseConnection (Lazarus 1.0.8/FPC 2.6.2 以降)。: mssqlconn/jaも参照のこと。
  3. Zeos コンポーネントの TZConnection (最新の CVS は、このページのどこかにある Zeos へのリンク先を見てください。)
    1. On Windows you can choose between native library ntwdblib.dll (protocol mssql) or FreeTDS libraries (protocol FreeTDS_MsSQL-nnnn) where nnnn is one of four variants depending on the server version. For Delphi (not Lazarus) there is also another Zeos protocol ado for MSSQL 2005 or later. Using protocols mssql or ado generates code not platform independient.
    2. On Linux the only way is with FreeTDS protocols and libraries (you should use libsybdb.so).
  4. ODBC (MSSQL and Sybase ASE) with SQLdb TODBCConnection (consider using TMSSQLConnection and TSybaseConnection instead)
    1. See also [1]
    2. On Windows it uses native ODBC Microsoft libraries (like sqlsrv32.dll for MSSQL 2000)
    3. On Linux it uses unixODBC + FreeTDS (packages unixodbc or iodbc, and tdsodbc). Since 2012 there is also a Microsoft SQL Server ODBC Driver 1.0 for Linux which is a binary product (no open source) and provides native connectivity, but was released only for 64 bits and only for RedHat.

Lazarus と ODBC

ODBC is a general database connection standard which is available on Linux, Windows and OSX. You will need an ODBC driver from your database vendor and set up an ODBC "data source" (also known as DSN). You can use the SQLDB components (TODBCConnection) to connect to an ODBC data soruce. See ODBCConn for more details and examples.

Microsoft Access

You can use the ODBC driver on Windows as well as Linux to access Access databases; see MS Access

Lazarus と Oracle

  • See Oracle. Access methods include:
  1. Built-in SQLDB support
  2. Zeos
  3. Oracle data access Lazarus component

Lazarus と PostgreSQL

  • PostgreSQL is very well supported out of the box by FPC/Lazarus
  • Please see postgres for details on various access methods, which include:
  1. Built-in SQLdb support. Use component TPQConnection from the SQLdb tab of the Component Palette
  2. Zeos. Use component TZConnection with protocol 'postgresql' from palette Zeos Access
  3. PostgreSQL data access Lazarus component

Lazarus と SQLite

SQLite is an embedded database; the database code can be distributed as a library (.dll/.so/.dylib) with your application to make it self-contained (comparable to Firebird embedded). SQLite is quite popular due to its relative simplicity, speed, small size and cross-platform support.

Please see the SQLite page for details on various access methods, which include:

  1. Built-in SQLDb support. Use component TSQLite3Connection from palette SQLdb
  2. Zeos
  3. SQLitePass
  4. TSQLite3Dataset
  5. SQLite data access Lazarus components

Lazarus と Firebird/Interbase

InterBase (and FireBird) Data Access Components (IBDAC) is a library of components that provides native connectivity to InterBase, Firebird and Yaffil from Lazarus (and Free Pascal) on Windows, Mac OS X, iOS, Android, Linux, and FreeBSD for both 32-bit and 64-bit platforms. IBDAC-based applications connect to the server directly using the InterBase client. IBDAC is designed to help programmers develop faster and cleaner InterBase database applications.

IBDAC is a complete replacement for standard InterBase connectivity solutions. It presents an efficient alternative to InterBase Express Components, the Borland Database Engine (BDE), and the standard dbExpress driver for access to InterBase.

Firebird data access components for Lazarus are free to download.

Lazarus と dBase

FPC includes a simple database component that is derived from the Delphi TTable component called "TDbf" TDbf Website). It supports various DBase and Foxpro formats.

TDbf does not accept SQL commands but you can use the dataset methods etc and you can also use regular databound controls such as the DBGrid.

It doesn't require any sort of runtime database engine. However it's not the best option for large database applications.

See the TDbf Tutorial page for the tutorial as well as documentation.

You can use e.g. OpenOffice/LibreOffice Base to visually create/edit dbf files, or create DBFs in code using TDbf.

Lazarus と Paradox

Paradox was the default format for database files in old versions of Delphi. The concept is similar to DBase files/DBFs, where the "database" is a folder, and each table is a file inside that folder. Also, each index is a file too. To access this files from Lazarus we have these options:

  • TParadox/ja: Install package "lazparadox 0.0" included in the standard distribution. When you install this package, you will see a new component labeled "PDX" in the "Data Access" palette. This component is not standalone, it uses a "native" library, namely the pdxlib library which is available for Linux and Windows. For example, to install in Debian, you could get pxlib1 from package manager. In Windows you need the pxlib.dll file.
  • TPdx/ja: Paradox DataSet for Lazarus and Delphi from this site. This component is standalone (pure object pascal), not requiring any external library, but it can only read (not write) Paradox files. The package to install is "paradoxlaz.lpk" and the component should appear in the "Data Access" palette with PDX label (but orange colour).
  • TParadoxDataSet/ja: is a TDataSet/ja that can only read Paradox Files up to Version 7. The approach is similar to the TPdx component, the package to install is "lazparadox.lpk" and the component should also appear in the "Data Access" palette.

TSdfDataset and TFixedDataset

TSdfDataSet/ja and TFixedFormatDataSet/ja are two simple TDataSet/ja descandants which offer a very simple textual storage format. These datasets are very convenient for small databases, because they are fully implemented as an Object Pascal unit, and thus require no external libraries. Also, their textual format allows them to be easily viewed/edited with a text editor.

サンプルコードとしては、 CSV/ja もご覧ください。

Lazarus と Advantage Database Server

関連情報

(アルファベット順にソートしています。)

外部リンク

  • Pascal Data Objects - a database API that worked for both FPC and Delphi and utilises native MySQL libraries for version 4.1 and 5.0 and Firebird SQL 1.5, and 2.0. It's inspired by PHP's PDO class.
  • Zeos+SQLite Tutorial - Good tutorial using screenshots and screencasts it explain how to use SQLite and Zeos, spanish (google translate does a good work in translating it to english)