Difference between revisions of "Lazarus Database Tutorial/ja"

From Lazarus wiki
Jump to navigationJump to search
(37 intermediate revisions by 2 users not shown)
Line 9: Line 9:
 
データアウェアコンポーネントは、IDE上の"Data Controls"タブ上にあり、データソースとデータベースのコントロールは"Data Access"タブ上にあります。
 
データアウェアコンポーネントは、IDE上の"Data Controls"タブ上にあり、データソースとデータベースのコントロールは"Data Access"タブ上にあります。
  
== Lazarus and MySQL ==
+
== Lazarus MySQL ==
  
=== Get MySQL working in Linux or Windows ===
+
=== MySQLをLinuxやWindowsで動作させる ===
Follow the instructions in the MySQL User Manual.  Make sure that the mysqld daemon runs reliably, and that all potential users (including root, mysql, yourself and anybody else that may need it) have as many privileges as they need, from as many hosts as may be needed (including 'localhost', the local host's name, any other hosts on your network) as far as is consistent with security. It is preferable that all users including root have passwords. Test the action of the database system using the examples given in the manual, and check that all users really do have reliable access.
+
MySQL User Manualの指示に従って進めてください。インストール後、mysqldデーモンが動作していることを確認してください。また、セキュリティを保ちうる範囲で、すべての必要なホスト('localhost',ホスト名,ネットワーク上の他のホスト名)から、すべての必要なユーザー(ルート、mysql、あなた自身、他に必要なユーザーを含む)に、必要な権限が与えられているか、確認してください。
 +
 
 +
ルートを含むすべてのユーザがパスワードを持っているのが、望ましいです。 マニュアルにある例でデータベース・システムの機能をテストしてください。そして、本当にすべてのユーザが信頼できるアクセスができるかチェックしてください。
 +
 
 +
(訳注:データベースに接続できない場合、プログラムのプロパティの設定が悪い場合もありますが、そもそも、プログラムの前に、インストール、PCの設定、ユーザー、それぞれの権限の設定がきちんとできているか、データベースのサンプルなどであらかじめ確認しておくことが必要です。)
 +
 
 +
=== MySQLをFPCのテキストモードで動かしてみよう ===
 +
例となるフォルダが$(fpc<b>src</b>dir)/packages/base/mysql/にあります。
 +
LazarusのIDEで、menu -> Environment Options -> Paths tab -> FPC source directoryにFPCのソースディレクトリがあります。MySQLが置いてある可能性のあるディレクトリは、rpmによるインストールだと、/usr/share/fpcsrc/packages/base/mysql/ Windowsでは C:\lazarus\fpcsrc\packages\base\mysql\です。
 +
 
 +
このディレクトリには、mysql.pp, mysql_com.pp そして mysql_version.ppがあります。
 +
テストスクリプトを実行する前に、testdbというデータベースを生成する必要があります。
 +
これをおこなうには、MySQL monitorにrootとして、全権限をもってログインして、次のステートメントを発行します。
  
=== Get MySQL working for FPC in text mode ===
 
There is a directory with an example program in $(fpc<b>src</b>dir)/packages/base/mysql/. You can find the fpc source directory in Lazarus: Environment menu -> Environment Options -> Paths tab -> FPC source directory. Possible paths for the mysql directory are /usr/share/fpcsrc/packages/base/mysql/ (rpm install) or C:\lazarus\fpcsrc\packages\base\mysql\ (windows). This directory also contains the units mysql.pp, mysql_com.pp and mysql_version.pp.  Before running the test script, you need to create a database called testdb:  do this by logging into the mysql monitor (as root with full privileges) and issuing the following SQL statement
 
 
  CREATE DATABASE testdb;
 
  CREATE DATABASE testdb;
then make sure that all relevant users have appropriate access privileges to it
+
 
 +
それから、すべて関連しているユーザが適切なアクセス権を持っていることを確認してください。
 +
 
 
  GRANT ALL ON testdb TO johnny-user IDENTIFIED BY 'johnnyspassword';  
 
  GRANT ALL ON testdb TO johnny-user IDENTIFIED BY 'johnnyspassword';  
There is a script called mkdb which you should now try to run:
+
 
 +
ここに、いま実行すべきであるmkdbと呼ばれるスクリプトがあります。
 +
 
 
  sh ./mkdb
 
  sh ./mkdb
This will probably fail, as the system will not allow an anonymous user to access the database.  So change the script using an editor so that the line invoking mysql reads:
+
 
 +
システムが、匿名のユーザにデータベースへのアクセスを許可していないとき、これはたぶん失敗するでしょう。
 +
その場合は、エディタをつかって、MySQLがその行を呼び出すように、スクリプトを変更してください。
 +
 
 
  mysql -u root -p  ${1-testdb} << EOF >/dev/null
 
  mysql -u root -p  ${1-testdb} << EOF >/dev/null
and try running it again, entering your password when prompted.  With luck you might have managed to create the test database:  test it (while logged in to the mysql monitor) by issuing the mysql statement
+
 
 +
そして、再度mkdbを走らせてみます。プロンプトが出たら、パスワードを入力してください。
 +
 
 +
 
 +
幸運にも、あなたは何とかテストデータベースを作成したに違いありません。MySQL monitorにログインしている間、 MySQLステートメントを発行して、テストしてください。
 +
 
 
  select * from FPdev;
 
  select * from FPdev;
You should see a table listing the ID, username and email address of some of the FPC developers.
 
  
Now try to run the test program testdb.pp (this may need to be compiled, and will almost certainly fail on the first attempt!!).
+
そうすると、FPC開発者のID,ユーザー名、電子メールアドレスが表記されているテーブルを見ることができるでしょう。
  
I found that the program could not connect to mysql for several reasons:
+
今度は、testdb.ppというプログラムを実行させてみてください。
 +
(これは、コンパイルしてください。ほとんど最初は失敗するでしょうけど)
 +
私はこのプログラムはいくつかの理由でmysqlに接続できないことを発見しました。
  
* My system (SuSE Linux v9.0) installs mysql v4.0.15, not the version3 for which the package was designed. 
+
* 私の環境(SuSE Linux v9.0)mysql v4.0.15をインストールしました。パッケージが設計されたバージョン3ではありません。
  
* The program needs to have user names and passwords to get access to the database.
+
* プログラムはデータベースにアクセスするためにユーザー名、パスワードが必要です。
  
* The compiler needs to know where to find the mysql libraries (IF YOU HAVEN'T INSTALLED THE MYSQL DEVELOPMENT LIBRARIES, DO SO NOW!)
+
* コンパイラに、どこにmysqlのライブラリを探せばいいか知らせる必要があります。(もしMySQLの開発ライブラリをインストールしていなければ、今インストールしましょう。)
  
I created a copy of testdb.pp called trydb.pp, rather than editing the original - this means that the original files still get fixed in subsequent CVS updates.
+
私はオリジナルを修正したくなかったのでtestdb.ppからtrydb.ppと名づけてコピーを作成しました。オリジナルファイルはCVSを使ったアップデートで修正されてしまうからです。
I also copied the files found in the subdirectory mysql/ver40/ into the main mysql/ subdirectory, renaming them mysql_v4.pp, mysql_com_v4.pp and mysql_version_v4.pp, being sure to rename the units within each file correspondingly. I changed the uses statement in trydb.pp to
+
 
 +
私はさらに、mysql/ver40/というサブディレクトリの中のファイル群を、 メインのmysql/サブディレクトリに、それぞれのファイルの名前が規則性をたもつように、mysql_v4.pp, mysql_com_v4.pp,mysql_version_v4.ppと名前をかえてコピーしました。
 +
 
 +
私はtrydb.ppのusesを次のように変更しました。
 
  uses mysql_v4
 
  uses mysql_v4
and the statement in mysql_v4.pp to
+
そして、mysql_v4.ppのusesも次のように変更しました。
 
 
 
  uses mysql_com_v4
 
  uses mysql_com_v4
  
I added a line to /etc/fpc.cfg to point to my libraries:
+
/etc/fpc.cfgに、自分のライブラリを指すように次の行を加えました。
 
  -Fl/lib;/usr/lib
 
  -Fl/lib;/usr/lib
The following step might not be necessary if the devel-libraries are installed as the links will be created for you, but it never hurts to check.
+
 
I had to find the real name of the mysqlclint library in the /usr/lib directory and in my case I had to issue the shell command:
+
次のステップは、devel-librariesがあなたのためにリンクとしてインストールされている場合、必要ないかもしれませんが、チェックして損はありません。
 +
 
 +
私は/usr/libディレクトリのmysqlclintライブラリの本当の名前を調べる必要がありました。そして、私の場合、シェルコマンドを発行しました。
 +
 
 
  ln -s libmysqlclient.so.12.0.0 lmysqlclient
 
  ln -s libmysqlclient.so.12.0.0 lmysqlclient
to make a symbolic link allowing FPC to find the library.  For good measure I also created the link
+
 
 +
FPCがライブラリを見つけられるよう、シンボリックリンクを生成するために、です。
 +
また、私は次のようなリンクを作成しました。
 +
 
 
  ln -s libmysqlclient.so.12.0.0 mysqlclient
 
  ln -s libmysqlclient.so.12.0.0 mysqlclient
and placed similar links in various other directories:  not strictly necessary, but just in case ...!
+
 
Some users might need to add the following link:
+
そして、同じように色々なほかのディレクトリのリンクを設置しました。
 +
厳密には、必要ではないのですが、このケースではそうしました。
 +
 
 +
他のユーザーでは、次のようなリンクが必要かもしれません。
 
  ln -s libmysqlclient.so.12.0.0 libmysqlclient.so
 
  ln -s libmysqlclient.so.12.0.0 libmysqlclient.so
  
I modified trydb.pp to include user details, initially by adding host, user and password as constants:
+
私はtrydb.ppをユーザーの詳細を含むように修正しました。最初にhost,user,passwordを定数としてもつように。
  
 
  const
 
  const
Line 62: Line 96:
 
   passwd: Pchar = 'mypassword';
 
   passwd: Pchar = 'mypassword';
  
I also found that I couldn't connect to mysql using the mysql_connect() call, but had to use mysql_real_connect() which has many more parameters.  To complicate things further, the number of parameters seems to have changed between version3 (where there are seven) and version4 (where there are eight).  Before using mysql_real_connect I had to use mysql_init() which is not found in the original mysql.pp but is found in mysql_v4.pp.
+
それでも私は、mysql_connect()をコールしても、まだmysqlに接続できないでいました。しかし、より多くのパラメータを必要とするmysql_real_connect()を使うべきだったのです。さらに物事を複雑にしていたのは、多くのパラメータがversion3(パラメータは7個)とversion4(パラメータは8個)の間で変わっているように思えました。
 +
 
 +
また、mysql_real_connectを使う前に、mysql_init()を使う必要がありました。
 +
これは、オリジナルのmysql.ppにはありませんでしたが、mysql_v4.ppにはあります。
  
So the code for connection to the database is now:
+
ここまでで、接続するためのコードは次のようになりました。
  
 
  { a few extra variables}
 
  { a few extra variables}
Line 108: Line 145:
 
  {... as original contents of testdb.pp}
 
  {... as original contents of testdb.pp}
  
 
+
それでは、tyrdb.ppのコンパイルを開始する準備はいいですか?
Now - ready to start compiling trydb.pp?
 
 
   fpc trydb
 
   fpc trydb
success!  Now run it:
+
成功しました!それでは実行してみましょう。
 
   ./trydb
 
   ./trydb
whoopee!  I got the listing of the FPC developers!
+
おっ!FPC開発者のリストの一覧を得ることができました!
  
A few extra refinements:  make the entry of user details and the mysql commands interactive, using variables rather than constants, and allow several SQL commands to be entered, until we issue the quit command: see the [[Lazarus Database Tutorial/TryDbpp|full program listing]], where user details are entered from the console, and the program goes into a loop where SQL commands are entered from the console (without the terminal semicolon) and the responses are printed out, until 'quit' is entered from the keyboard.
+
いくつかの、さらなる改善点があります。
 +
ユーザーに関する詳細のエントリを作る時、あるいは、MySQLのコマンドを双方向にしたいとき、定数よりは変数の方がいいでしょう。そして、いくつかの発行したいSQLコマンドに、結果を返さないコマンドでも([[Lazarus Database Tutorial/TryDbpp|full program listing]]を見てください)ユーザーの詳細情報をコンソールから入力する部分、プログラムがSQLコマンドがコンソールから入力されるループにはいる部分、結果等について、quitがキーボードから入力されるまで、プリントアウトできるようにしてください。
  
See [[Lazarus Database Tutorial/SampleListing|Sample Console Listing]].
+
こちらを見てください。[[Lazarus Database Tutorial/SampleListing|Sample Console Listing]]
  
===Connecting to MySQL from a Lazarus Application ===
+
===LazarusアプリケーションからMySQLへの接続===
  
This tutorial shows how to connect Lazarus to the MySQL database, and execute simple queries, using only the basic Lazarus components; it uses no Data Aware components, but illustrates the principles of interfacing with the database.
+
このチュートリアルでは、基本的なLazarusコンポーネントのみを使って、LazarusでどのようにMySQLに接続するか、そして簡単なクエリを実行するかを示します。
 +
このとき、Data Aware コンポーネントは使いません。しかし、データベースとインターフェースする原理を解説します。
  
Create a new project in Lazarus:
+
Lazarusで新しいプロジェクトを生成してください。
 
  Project -> New Project -> Application
 
  Project -> New Project -> Application
A new automatically generated Form will appear.
+
自動的に生成されたフォームが現れます。
 
+
フォームをスクリーンの半分くらいになるように大きくして、フォームの名前とキャプションを、'TryMySQL'としてください。
Enlarge the form to fill about half of the screen, then re-name the form and its caption to 'TryMySQL'.
 
  
From the Standard Component tab place three Edit Boxes on the upper left side of the Form, and immediately above each box place a label.  Change the names and captions to 'Host' (and HostLLabel,HostEdit), 'UserName' (and UserLabel, UserEdit) and 'Password' (with PasswdLabel and PasswdEdit).  Alternatively you could use LabelledEdit components from the Additional tab.
+
コンポーネントパレットのStandardのタブから、3つのエディットボックスを、フォームの左上のほうへ置いてください。そして、それぞれのエディットボックスの真上にラベルを置いてください。
 +
ラベルのキャプションを'Host'としてHostLabel,エディットをHostEditとしてください。
 +
同様に、'UserName'としてUserLabel,UserEditとしてください。
 +
同様に、'Password'としてPasswdLabel,PasswdEditとしてください。
 +
これらのかわりに、LabeledEditコンポーネントをAdditionalタブから使うことができます。
  
Select the Passwd Edit box and find the PasswordChar property:  change this to * or some other character, so that when you type in a password the characters do not appear on your screen but are echoed by a series of *s.  Make sure that the Text property of each edit box is blank.
+
PasswdEditを選択して、PasswordCharプロパティを見つけて、これを * か、他のキャラクタにしてください。そうすることで、画面にパスワードをキーボードから入力したときに表示されないように、かわりに、*の文字を表示するようにします。
 +
それぞれのエディットボックスのTextプロパティが空白であることを確認してください。
  
Now place another Edit box and label at the top of the right side of your form.  Change the label to 'Enter SQL Command' and name it CommandEdit.
+
ここでさらに、もうひとつエディットボックスとラベルを、フォームの右上に置いてください。
 +
ラベルのCaptionを、'Enter SQL Command'に、NameをCommadEditにしてください。
  
Place three Buttons on the form:  two on the left under the Edit boxes, and one on the right under the command box.
+
3つのボタンをフォームに置きます。2つは、EditBoxの下の左のほうへ、もう一つは、右のコマンドボックスの下へ置いてください。
  
Label the buttons on the left 'Connect to Database' (ConnectButton)and 'Exit' (ExitButton) and the one on the right 'Send Query' (QueryButton).
+
左のボタンは、Caption='Connect to Database'、Name='ConnectButton'、もうひとつは、Caption='Exit'、Name='ExitButton'としてください。右のボタンは Caption='Send Query'、Name='QueryButton'としてください。
  
Place a large Memo Box labelled and named 'Results' (ResultMemo) on the lower right, to fill most of the available space. Find its ScrollBars property and select ssAutoBoth so that scroll bars appear automatically if text fills the space.  Make the WordWrap property True.
+
大きなメモをフォームの右下に貼り付けて、使えるだけのスペースを使って配置して、'Result'と表示してName='ResultMemo'としてください。テキストがあふれたときに自動的にスクロールバーがつくように、ScrollBars='ssAutoBoth'にしてください。また、WordWrap='True'としてください。
  
Place a Status Bar (from the Common Controls tab) at the bottom of the Form, and make its SimpleText property 'TryMySQL'.
+
Commonコントロールタブから、ステータスバーをフォームの下に置き、SimpleText='TryMySQL'としてください。
  
A screenshot of the Form can be seen here: [http://lazarus-ccr.sourceforge.net/kbdata/trymysqldb.png Mysql Example Screenshot]
+
このフォームのスクリーンショットを置いておきます。:[http://lazarus-ccr.sourceforge.net/kbdata/trymysqldb.png Mysql Example Screenshot]
  
Now we need to write some event handlers.
+
これで、必要なイベントハンドラを書くことが出来ます。
 +
左にある3つのエディットボックスはホスト名、ユーザ名、パスワードの入力に使います。これらの3つの入力がきちんと終わったら、Connectボタンをクリックします。このボタンのOnClickイベントハンドラは、先ほどのテキストモードのFPCプログラムの一部とほとんど同じです。
  
The three Edit boxes on the left are for entry of hostname, username and password.  When these have been entered satisfactorily, the Connect Button is clicked.  The OnCLick event handler for this button is based on part of the text-mode FPC program above.
+
データベースからのレスポンスはPascalのwrite文やwriteln文を使って書かれてはいません。しかし、返答はstringsに変換され、Memoに表示されます。Pascalのwriteとwriteln文は沢山の型変換を実行時に行う能力がある一方、Memoを使ってテキストを出力する際に、明確なデータ型変換をstringの正しい形式にすることが必要です。なので、PChar変数はStrPasを使って変換されなければならず、Integer変数はIntToStrを使って変換されなければなりません。
  
The responses from the database cannot now be written using the Pascal write or writeln statements: rather, the replies have to be converted into strings and displayed in the Memo box.  Whereas the Pascal write and writeln statements are capable of performing a lot of type conversion 'on the fly', the use of a memo box for text output necessitates the explicit conversion of data types to the correct form of string, so Pchar variables have to be converted to strings using StrPas, and integers have to be converted with IntToStr. 
+
(訳注:Delphiで慣れた方々には当たり前に思えるかもしれませんが、本来、Pascalでの文字列形式出力はwriteやwritelnを使うものであり、それは、実行時に変数の型を明示しなくても、自動的に適切な文字列として表示することができます。)
  
Strings are displayed in the Memo box using
+
文字列はMemoに下記のような関数をつかって表示されます。
  
 
  procedure ShowString (S : string);
 
  procedure ShowString (S : string);
Line 159: Line 203:
 
  end;
 
  end;
  
The ConnectButton event handler thus becomes:
+
Connectボタンのイベントハンドラは次のようにします。
  
 
  procedure TtrymysqlForm1.ConnectButtonClick(Sender: TObject);
 
  procedure TtrymysqlForm1.ConnectButtonClick(Sender: TObject);
Line 203: Line 247:
 
  end;
 
  end;
  
 +
右のテキストボックスはSQL文を入力するものです。終了のセミコロンなしで良いです。
 +
きちんとしたSQL文を入力して、SendQueryボタンを押すとクエリが実行され、ResultMemoの中に結果が表示されます。
  
The Text Box on the right allows entry of a SQL statement, without a terminal semicolon;  when you are satisfied with its content or syntax, the SendQuery button is pressed, and the query is processed, with results being written in the ResultsMemo box.
+
SendQueryのイベントハンドラもFPCのテキストモードの時とほとんど同じですが、表示の際に明示的な型変換をおこなうことを除いてという点は、先ほどの例と同じです。
 
 
The SendQuery event handler is again based on the FPC text-mode version, except that once again explicit type-conversion has to be done before strings are displayed in the box.
 
  
A difference from the text-mode FPC program is that if an error condition is detected, the program does not halt and MySQL is not closed;  instead, control is returned to the main form and an opportunity is given to correct the entry before the command is re-submitted.  The application finally exits (with closure of MySQL) when the Exit Button is clicked.
+
テキストモードのFPCプログラムと違う点は、エラーが検出されたときにプログラムは停止せず、MySQLもクローズされないところです。そのかわり、制御がメインフォームに戻り、コマンドが再発行できるように修正する機会が与えられます。
  
The code for SendQuery follows:
+
アプリケーションは最終的に、Exitボタンがクリックされたときに、MySQLをクローズして終了します。
 +
SendQueryは次のようになっています。
  
 
  procedure TtrymysqlForm1.QueryButtonClick(Sender: TObject);
 
  procedure TtrymysqlForm1.QueryButtonClick(Sender: TObject);
Line 250: Line 295:
 
  end;
 
  end;
  
 +
プロジェクトを保存して、メニューからRun -> Runを選んでください。
  
Save your Project, and press Run -> Run
+
==== MySQLのソースコードをダウンロードする ====
 +
全ソースコードは次からダウンロードできます。[http://lazarus-ccr.sourceforge.net/kbdata/mysqldemo.tar.gz Sample Source Code]
  
==== Download MYSQL Source Code ====
+
== Lazarus と PostGreSQL ==
A full listing of the  program is available here [http://lazarus-ccr.sourceforge.net/kbdata/mysqldemo.tar.gz Sample Source Code]
+
これは、Lazarus 0.9.12以降と、PostGresSQLデータベースを、ローカル、リモートの両方でTPQConnectionを使って接続するためのとても短いチュートリアルです。
  
== Lazarus and Postgresql ==
+
インストールを正しくおこなったの後で、次のステップをやってみてください。
  
This is a very short tutorial to get Lazarus 0.9.12 or later to connect to a PostGreSQL database, local or remote, using TPQConnection.
+
* SQLdbタブから、PQConnectionを置く
 +
* SQLdbタブから、SQLQueryを置く
 +
* SQLdbタブから、SQLTransactionを置く
 +
* DataAccessタブから、DataSourceを置く
 +
* DataControlsタブから、DBGridを置く
  
After correct install, follow these steps:
+
* PQConnectionのプロパティを適切に設定してください。
 
+
** transaction propertyに、SQLTransactionオブジェクトを参照させる。
* Place a PQConnection    from the SQLdb tab
 
* Place a SQLQuery        from the SQLdb tab
 
* Place a SQLTransaction  from the SQLdb tab
 
* Place a DataSource      from the DataAccess tab
 
* Place a DBGrid          from the DataControls tab
 
 
 
* In the PQConnection fill in:
 
** transaction property with the respective SQLTransaction object
 
 
** Database name
 
** Database name
 
** HostName
 
** HostName
 
** UserName + password
 
** UserName + password
  
* Check that the SQLTransaction was automatically changed to point to the PQConnection
+
* SQLTransactionが自動的にPQConnectionを示すように変更されたとこに注意してください。
  
* In the SQLQuery fill in:
+
* SQLQueryのプロパティを適切に埋めてください。
** transaction property with the respective object
+
** transaction プロパティに適切なオブジェクト
** database property with respective object
+
** database プロパティに適切なオブジェクト
** SQL (something like 'select * from anytable')
+
** SQL (たとえば、'select * from anytable' などとしてください。)
  
* In the DataSource object fill in the DataSet property with the SQLQuery object
+
* DataSourceオブジェクトのDataSetプロパティに、SQLQueryオブジェクトを指定してください。
  
* In the DBGrid fill in the datasource as the DataSource Object
+
* DBGridオブジェクトのDataSourceプロパティにDataSourceオブジェクトを設定してください。
  
Turn everything to connected and active and the DBGrid should be filled in design time.
+
すべてをconnectedとactiveにすると、設計時においても、DBGridに表示がされます。
TDBText and TDBEdit seem to work but (for me) they only _show_ _data_.
+
TDBTextとTDBEditは、私には、ただ値を表示するだけのように見えます。
  
 
To change contents in the database, I called the DB Engine direct with the following code:
 
To change contents in the database, I called the DB Engine direct with the following code:
 +
データベースの内容を更新するには、私は次のようにDBエンジンをダイレクトに呼び出します。
 +
 
   try
 
   try
 
     sql:= 'UPDATE table SET setting=1';
 
     sql:= 'UPDATE table SET setting=1';
Line 304: Line 349:
  
  
* Notes:
+
* ノート:
** Tested on windows, Lazarus 0.9.12 + PGSQL 8.3.1
+
** Lazarus 0.9.12 + PGSQL 8.3.1にて、Windowsでテストしました。
** Some tests in linux, Lazarus 0.9.12 and PGSQL 8.0.x
+
** Lazarus 0.9.12 and PGSQL 8.0.xで、Linuxでテストしました。
  
  
* Instalation and errors:
+
* インストレーションとエラー:
** In the tested version of Lazarus .12, fields of type "text" and "numeric" have bugs
+
** Lazarus 0.9.12のテストバージョン では、"text" "numeric" の型にバグがあります。
** I used with no problems char fixed size, int and float8
+
** 固定長のキャラクタと、intとfloat8では、私は問題なく使えました。
** Sometimes restarting Lazarus solves stupid errors...
+
** 時々Lazarusを再起動することでくだらないエラーを解決できた
** After some errors, the transactions remain active and should be deactivated mannually
+
** いくつかのエラーの後で、トランザクションがアクティブのまま残り、手動でデアクティベートしなくてはならなかった。
** Changes made in Lazarus are of course not visible until transaction commited
+
** Lazarusによって行われた変更は、もちろん、トランザクションがコミットされるまでは見ることができません。(訳注:他のトランザクションでは、ということ)
** The integrated debugger seems buggy (at least in windows) - sometimes running outside of the IDE may help to find errors
+
** IDEのデバッガは(少なくともWindowsにおいては)バグがあるようです。時々IDEの外で走らせるとエラーの発生を見つけるのに役立ちます。
** In linux certain error messages are printed in the console -- run your program in the command line, sometimes there is some extra useful debugging info
+
** Linuxでは、特定のエラーメッセージがコンソールに出力されることがあります。--もし、コマンドラインで走らせているなら、時々デバッグに役立つ情報があります。
** Error: "Can not load Postgresql client. Is it installed (libpq.so) ?"
+
** このようなエラーが発生することがあります。: "Can not load Postgresql client. Is it installed (libpq.so) ?"
*** Add the path to seach libpq* from the PostgreSQL installation.
+
*** PostgreSQLをインストールした所から、libpq*を探して、パスに加えて下さい。
*** In linux add the path to the libpq.so file to the libraries section in your /etc/fpc.cfg file. For example : -Fl/usr/local/pgsql/lib
+
*** Linuxでは、pathにlibpq.soファイルを、/etc/fpc.cfgの中のライブラリセクションに加えてください。たとえば、次のように:-Fl/usr/local/pgsql/lib
*** In windows, add these libs anywhere in the Path environment variable or project dir
+
*** Windowsでは、これらのライブラリを、環境変数のパスのどこにでも追加してください。また、プロジェクトディレクトリに加えてもかまいません。
***  I windows, I copied all the DLLs in my C:\Program Files\PostgreSQL\8.1\bin dir to another dir in the PATH
+
***  私は、すべてのDLLを自分のパソコンのC:\Program Files\PostgreSQL\8.1\bin などに入れて、パスを通しています。
***  Or add this postgres\bin dir to the path
 
  
== Lazarus and SQLite ==
+
== Lazarus SQLite ==
  
by Luiz Américo
+
Luiz Américo による
  
===Introduction===
+
===イントロダクション===
  
TSqliteDataset and TSqlite3Dataset are TDataset descendants that access, respectively, 2.8.x and 3.2.x sqlite databases. Below is a list of the principal advantages and disadvantages:
+
TSQLLiteDatasetとTSQLLite3DatasetはTDatasetの派生クラスで、2.8.xと3.2.xのSQLLiteデータベースにアクセスします。下記は主な特徴と欠点です。
  
Advantages:
+
特徴:
  
* Flexible: programmers can choose to use or not to use the SQL language, allowing them to work with simple table layouts or any complex layout that SQL/sqlite allows
+
* 自由度が高い: データベースはシンプルなテーブルレイアウトでも、複雑なSQLを使ってもよいので、プログラマは、SQLを使っても良いし、使わなくても良い。
* Automatic database update: no need to  update the database manually with SQL statements, a single method take cares of it
+
* 自動データ更新: SQL文でデータベースを手動でアップデートする必要はありません。1つの命令で更新ができます。
* Fast: it caches the data in memory, making browsing in the dataset fast
+
* 高速: メモリにデータをキャッシュするため、データセットを高速にブラウズします。
* No server instalation/configuration: just ship together with sqlite dynamic library
+
* サーバーインストール、設定が不要:SQLLiteダイナミックライブラリと一緒に配布するだけです。
  
Disavantages
+
欠点
  
* Requires external file (sqlite library)
+
* 外部ファイルを必要とします。(sqlite library)
  
===Requirements===
+
===要求事項===
  
* For sqlite2 databases:
+
* sqlite2のためには:
 
** fpc 2.0.0
 
** fpc 2.0.0
 
** Lazarus 0.9.10
 
** Lazarus 0.9.10
** sqlite runtime library 2.8.15 or above (get from www.sqlite.org)
+
** sqlite runtime library 2.8.15 以上(www.sqlite.orgから)
  
* For sqlite3 databases:
+
* sqlite3のためには:
 
** fpc 2.0.2
 
** fpc 2.0.2
** Lazarus 0.9.11 (svn revision 8443 or above)
+
** Lazarus 0.9.11 (svn revision 8443 以上)
** sqlite runtime library 3.2.1 or above (get from www.sqlite.org)
+
** sqlite runtime library 3.2.1 以上 (www.sqlite.orgから)
  
'''Before initiating a lazarus projects, ensure that:'''
+
'''Lazarusのプロジェクトを作る前に、次の事を確認してください。:'''
* the sqlite library is on the system PATH or in the executable directory
+
* SQLLiteライブラリがシステムパスか、実行できるディレクトリにあるかどうか。
* under Linux, put cmem as the first unit in uses clause of the main program
+
* Linuxでは、cmemを メインプログラムのusesの最初のユニットにしているかどうか
  
===How To Use (Basic Usage)===
+
===使い方 (基本)===
  
Install the package found at /components/sqlite directory (see instructions [[Install_Packages|here]])
+
/components/sqlite にあるパッケージをインストールしてください。([[Install_Packages|ここ]]にその方法があります。)
 +
設計時に下記のプロパティをセットして下さい。
  
At design time set the following properties:
+
* FileName: sqliteファイルへのパス[必須]
 +
* TableName: sql文で使うテーブル名[必須]
 +
* Sql: SQLのSELECT文 [必要に応じて]
  
* FileName: path of the sqlite file [required]
+
'''テーブルを作成する(Dataset)'''
* TableName: name of the table used in the sql statement [required]
 
* Sql: a SQL select statement [optional]
 
  
'''Creating a Table (Dataset)'''
+
コンポーネントアイコンをダブルクックするか、右マウスボタンのクリックで現れるポップアップメニューで、'Create Table'を選択します。
  
Double click in the component icon or use the 'Create Table' item of the popup menu that appears when clicking the right mouse button.
+
簡単な説明のあるテーブルエディタが表示されます。
A simple self-explaining table editor will be show.
+
 
 +
  下記はTSqliteDatasetとTSqlite3Datasetでサポートされているすべてのフィールドの型です。
  
  Here is all field types supported by TSqliteDataset and TSqlite3Dataset:
 
 
 
 
   Integer
 
   Integer
 
   AutoInc
 
   AutoInc
Line 389: Line 433:
 
   Currency
 
   Currency
 
    
 
    
'''Retrieving the data'''
+
'''データを取得する'''
  
After creating the table or with a previously created Table, open the dataset with Open method.
+
テーブルを生成した後か、以前作ったテーブルで作業する場合、Open手続きでデータセットを開いて下さい。
If the SQL property was not set then all records from all fields will be retrieved, the same if you set the SQL to:
+
SQLプロパティがセットしていない場合、すべてのフィールドのすべてのレコードを取得するためには、次のような1文をSQLにセットします。:
  
 
   SQL:='Select * from TABLENAME';  
 
   SQL:='Select * from TABLENAME';  
  
'''Applying changes to the underlying datafile'''
+
'''データファイル上に変更を保存する'''
  
To use the ApplyUpdates function, the dataset must contain at least one field that fills the requirements for a Primary Key (values must be UNIQUE and not NULL)
+
ApplyUpdates関数を使うために, データセットは主キーの条件にあうための、少なくとも1つのフィールドを持っていなければなりません。(つまり、ユニークであって、NULLではない、という条件です。)
  
It's possible to do that in two ways:
+
更新をおこなうために2つの方法が可能です。
  
* Set PrimaryKey property to the name of a Primary Key field
+
* PrimaryKeyプロパティに主キーになっているフィールド名を指定する。
* Add an AutoInc field (This is easier since the TSqliteDataSet automatically handles it as a Primary Key)
+
* AutoIncフィールドを加える。(これはTSqliteDatasetが自動的にそれを主キーとしてみなすので簡単です。)
  
If one of the two conditions is set then just call
+
もし、2つの条件のうち、1つをセットしたら、次のように呼び出すだけです。
 
    
 
    
 
   ApplyUpdates;
 
   ApplyUpdates;
  
PS1: If both conditions are set, the field corresponding to PrimaryKey is used to apply the updates.
+
追記1: もし、両方の条件がセットされたら、主キーによるフィールドが更新のために使われます。
 +
 
 +
追記2:フィールドに主キーを設定することは、ApplyUpdateがコールされたときに、主キーによってデータをみつけられなくてはいけません。
 +
ですから、選択されたフィールドは、 Nullを含まないことや、一意であることを確認してください。
  
PS2: Setting PrimaryKey to a field that is not a Primary Key will lead to loss of data if ApplyUpdates is called, so ensure that the chosen field contains not Null and Unique values before using it.
+
===注意事項===
  
===Remarks===
+
* 10000レコードまではテストして、上手く動きますが、TSqliteDatasetはすべてのデータをメモリ上に置くため、必要なデータのみ受け取るようにしてください。(特にMemoフィールドなどに注意).
 +
* 同じデータファイルに、いくつかのテーブル、データセットを持たせることができます。
 +
* いくつかのデータセット(違うフィールドの組み合わせの)を同じテーブルから作ることができます。
 +
* SQLでWHERE文を使ってデータを選別することが可能です。クローズして再オープンする(あるいは、RefechDataメソッドをつかう)ことができます。この場合、並び順やフィールドの数は同じでなくてはなりません。
 +
* 複数のテーブルからaliasesやjoin,viewsなどを使って複雑なSQL文を使うことが可能です。(しかし、これらは同じデータファイルになくてはなりません。)しかしこの場合、ApplyUpdateは動作しません。もし複雑なクエリをつかって、データファイルに更新を加えたければ私(Luiz Américo)にメールしてください。そうすれば、どういうふうにおこなうか、ヒントをお伝えすることができます。
  
* Although it has been tested with 10000 records and worked fine, TSqliteDataset keeps all the data in memory, so remenber to retrieve only the necessary data (principally with Memo Fields).
+
* TSqliteDatasetで生成されていない、そして、開いていないsqlite2.xのデータファイルにファイル名を設定するとき、一部のフィールドが正しい型を検出することが、許可されていません。これらは、stringフィールドとして扱われます。
* The same datafile (Filename property) can host several tables/datasets
 
* Several datasets (different combinations of fields) can be created using the same table simultaneously
 
* It's possible to filter the data using WHERE statements in the sql, closing and reopening the dataset (or calling RefetchData method). But in this case, the order and number of fields must remain the same
 
* It's also possible to use complex SQL statements using aliases, joins, views in multiple tables (remember that they must reside in the same datafile), but in this case ApplyUpdates won't work. If someone wants to use complex queries and to apply the updates to the datafile, mail me and I will give some hints how to do that
 
* Setting filename to a sqlite2.x datafile not created by TSqliteDataset and opening it is allowed but some fields won't have the correct field type detected. These will be treated as string fields.
 
  
Generic examples can be found at fpc/fcl/db/sqlite CVS directory
+
一般的なサンプルが、fpc/fcl/db/sqlite CVSディレクトリにあります。
  
 
Luiz Américo
 
Luiz Américo
 
pascalive(at)bol(dot)com(dot)br
 
pascalive(at)bol(dot)com(dot)br
  
== Lazarus and MSSQL ==
+
== Lazarus MSSQL ==
  
It is working with Zeoslib (latest cvs), see the links on bottom of page.
+
これはZeoslib (latest cvs)でおこなっています。ページの最後のリンクを見てください。
  
== Lazarus and Interbase / Firebird ==
+
== Lazarus Interbase / Firebird ==
  
See [[Install Packages|Install Packages]]. On this page is a first small example en explanation about how to connect to an IB or FB server.
+
[[Install Packages|Install Packages]]を見て下さい。このページにはどのようにIBやFBサーバーと接続するか、最初の小さいサンプルと説明があります。
  
Also work with the latest Zeoslib (from cvs).
+
この作業も最新のZeoslibにあります。
  
===FBLib Firebird Library===
+
===FBLib Firebird ライブラリ===
  
[http://fblib.altervista.org/|FBLib] is an open Source Library No Data Aware for direct access to Firebird Relational Database from Borland Delphi / Kylix, Freepascal and Lazarus.
+
[http://fblib.altervista.org/|FBLib] はDelphi/Kylix、FreePascalとLazarusからFirebirdリレーショナルデータベースに直接アクセスする、(DataAwareではない)オープンソースライブラリです。
  
Current Features include:
+
現在、次のような特徴があります。
  
* Direct Access to Firebird 1.0.x 1.5.x Classic or SuperServer
+
* Firebird 1.0.x 1.5.x Classic SuperServer に直接接続します。
* Multiplatform [Win32,Gnu/Linux,FreeBSD)
+
* マルチプラットホームです。 [Win32,Gnu/Linux,FreeBSD)
* Automatic select client library 'fbclient' or 'gds32'
+
* 自動的にクライアントライブラリを選択します。'fbclient' または 'gds32'
* Query with params
+
* パラメータ型クエリのサポート
* Support SQL Dialect 1/3
+
* SQL Dialect 1/3をサポート
* LGPL License agreement
+
* LGPL ライセンス
* Extract Metadata
+
* メタデータの抽出
* Simple Script Parser
+
* シンプルなスクリプトパーサ
* Only 100-150 KB added into final EXE
+
* 実行ファイルは100-150 KB しか増えません。
* Support BLOB Fields
+
* BLOB フィールドをサポートします。
* Export Data to HTML SQL Script
+
* HTML SQL Scriptへデータを出力します。
* Service manager (backup,restore,gfix...)
+
* サービスマネージャ (backup,restore,gfix...)
* Events Alerter
+
* イベントアラータ
  
You can download documentation on [http://fblib.altervista.org/ FBLib's website].
+
文書はここからダウンロードできます。[http://fblib.altervista.org/ FBLibのWebサイト].
  
== Lazarus and dBase ==
+
== Lazarus dBase ==
  
 
[[user:Tonymaro|Tony Maro]]
 
[[user:Tonymaro|Tony Maro]]
  
You might also want to visit the beginnings of the [[Lazarus Tdbf Tutorial|TDbf Tutorial page]]
+
このページも訪れるとよいでしょう。[[Lazarus Tdbf Tutorial|TDbf Tutorial page]]
 +
 
 +
FPCはDelphiのTTableコンポーネントとにた機能をもつ、"TDbf"([http://tdbf.sourceforge.net/ TDbf Website])と呼ばれる、シンプルなデータベースコンポーネントを含んでいます。
 +
これは、基本的なdBaseファイルの機能の基本的なサブセットをサポートしています。これは、デフォルトではインストールされませんので、最初にすることはLazarusパッケージを"lazarus/components/tdbf" からインストールして、Lazarus IDEをビルドすることです。そうすれば、コンポーネントパレットにTDatasourceの次に現れます。
  
FPC includes a simple database component that is similar in function to the Delphi TTable component called "TDbf" ([http://tdbf.sourceforge.net/ TDbf Website]) that supports a very basic subset of features for dBase files.  It is not installed by default, so you will first need to install the Lazarus package from the "lazarus/components/tdbf" directory and rebuild your Lazarus IDE.  It will then appear next to the TDatasource in your component palette.
+
TDbfコンポーネントは他のデータベースコンポーネントに対して、次のような利点があります。すなわち、どんな種類のランタイムデータベースエンジンも必要としないことです。しかしながら、大きいデータベースをもつアプリケーションには最適ではありません。
  
The TDbf component has an advantage over other database components in that it doesn't require any sort of runtime database engine, however it's not the best option for large database applications.
+
これを使うのは非常に簡単です。単に、フォームの上にTDbfをドロップしておいてください。ランタイムパスにデータベースファイルを置く場所を指定します。テーブル名をセットします。そして、TDatasourceコンポーネントにリンクします。
  
It's very easy to use.  Simply, put, drop a TDbf on your form, set the runtime path to the directory that your database files will be in, set the table name, and link it to your TDatasource component.
+
しかしながら、もうちょっと努力して本格的な機能が求められます。テーブルがすでに存在しない場合、テーブルデザイナに相当するものがなければ(私はしりませんが)、プログラムからそれをつくる必要があります。
  
Real functionality requires a bit more effort, however.  If a table doesn't already exist, you'll need to create it programmatically, unless there's a compatible table designer I'm not familiar with.
+
存在しないテーブルを開こうとすると、エラーが生成されます。テーブルはプログラムから、ランタイムパスとテーブル名をセットしたコンポーネントを通して、作ることができます。
  
Attempting to open a non-existant table will generate an error.  Tables can be created programmatically through the component after the runtime path and table name are set.
+
たとえば、あなたのDVDコレクションを記録するために"dvds"というテーブルを作る場合、フォームにTDbfコンポーネントをドロップして、ランタイムパスと"dvds"と名づけたテーブル名を設定してください
  
For instance, to create a table called "dvds" to store your dvd collection you would drop it on your form, set the runtime path, and set the table name to "dvds".  The resulting file will be called "dvds.dbf".
+
結果ファイルは"dvds.dbf"となります。
  
In your code, insert the following:
+
コードでおこなう場合次のようなコードを入れてください。
  
 
     Dbf1.FilePathFull := '/path/to/my/database';
 
     Dbf1.FilePathFull := '/path/to/my/database';
Line 488: Line 537:
 
     Dbf1.CreateTable;
 
     Dbf1.CreateTable;
  
When this code is run, your DVD collection table will be created.  After that, all data aware components linked through the TDatasource to this component will allow easy access to the data. 
+
このプログラムを走らせると、あなた用のDVDコレクションテーブルが作られます。その後、すべてのdata awareコンポーネントがTDatasourceを通してリンクされ、データに簡単にアクセスできるようになります。
 +
 
 +
インデックスを付加することは、典型的なTTableとはちょっと異なっています。データベースは開いていなくてはなりません。インデックスをリビルドするのと同じメソッドを使います。
  
Adding indexes is a little different from your typical TTable.  It must be done after the database is open.  It's also the same method you use to rebuild the indexes.  For instance:
+
例えば:
  
 
     Dbf1.Exclusive := True;
 
     Dbf1.Exclusive := True;
Line 498: Line 549:
 
     Dbf1.Close;
 
     Dbf1.Close;
  
The first (primary) index will be a file called "dvdsname.mdx" and the second will be a file named "rating.ndx" so in a multiple table database you must be careful not to use the same file name again.
+
最初のインデックス(プライマリインデックス)は、"dvdname.mdx"というファイルにはいっており、2番目のインデックスは、"rating.ndx"というファイルにはいっています。複数のテーブルがあるデータベースでは、同じファイル名を使わないよう注意を払ってください。
  
I will try to add a more detailed example at a later date, but hopefully this will get those old Delphi programmers up and running with databases in Lazarus!
+
今後、もっと詳細な例を作りたいと思っています。願わくば、昔Delphiに馴染んだ方々に立ち上がっていただき、Lazarusでデータベースのプログラムを作るきっかけになってほしいと思っています。
  
== Related Links ==
+
== 関連のある記事 ==
 
*[[Databases|Creating Databases Applications with Lazarus using the DB-unit]]<br>
 
*[[Databases|Creating Databases Applications with Lazarus using the DB-unit]]<br>
 
*[[MySQLDatabases|Creating a database application using MySQL]]<br>
 
*[[MySQLDatabases|Creating a database application using MySQL]]<br>

Revision as of 13:07, 9 November 2008

Deutsch (de) English (en) español (es) français (fr) Bahasa Indonesia (id) italiano (it) 日本語 (ja) Nederlands (nl) português (pt) русский (ru) 中文(中国大陆)‎ (zh_CN) 中文(台灣)‎ (zh_TW)

日本語版メニュー
メインページ - Lazarus Documentation日本語版 - 翻訳ノート - 日本語障害情報

概要

このチュートリアルは、Lazarusでいろいろなデータベースの操作を行うためのものです。 Lazarusでは、いくつかのデータベースを外部的にサポートしています。しかし、それぞれのデータベースにたいして開発者は適切なパッケージをインストールしなくてはなりません。 データベースには、コードを書いたり、フォーム上のコンポーネントをドロップしてアクセスすることができます。データアウェアコンポーネントは、DataSourceプロパティをTDatasetに設定することで、接続し、フィールドに対応して表示することができます。データソースはあるテーブルをあらわし、データベースコンポーネント(たとえば、TPSQLDatabase, TSQLiteDataSet)へDataSetプロパティをとおして接続されます。 データアウェアコンポーネントは、IDE上の"Data Controls"タブ上にあり、データソースとデータベースのコントロールは"Data Access"タブ上にあります。

Lazarus と MySQL

MySQLをLinuxやWindowsで動作させる

MySQL User Manualの指示に従って進めてください。インストール後、mysqldデーモンが動作していることを確認してください。また、セキュリティを保ちうる範囲で、すべての必要なホスト('localhost',ホスト名,ネットワーク上の他のホスト名)から、すべての必要なユーザー(ルート、mysql、あなた自身、他に必要なユーザーを含む)に、必要な権限が与えられているか、確認してください。

ルートを含むすべてのユーザがパスワードを持っているのが、望ましいです。 マニュアルにある例でデータベース・システムの機能をテストしてください。そして、本当にすべてのユーザが信頼できるアクセスができるかチェックしてください。

(訳注:データベースに接続できない場合、プログラムのプロパティの設定が悪い場合もありますが、そもそも、プログラムの前に、インストール、PCの設定、ユーザー、それぞれの権限の設定がきちんとできているか、データベースのサンプルなどであらかじめ確認しておくことが必要です。)

MySQLをFPCのテキストモードで動かしてみよう

例となるフォルダが$(fpcsrcdir)/packages/base/mysql/にあります。 LazarusのIDEで、menu -> Environment Options -> Paths tab -> FPC source directoryにFPCのソースディレクトリがあります。MySQLが置いてある可能性のあるディレクトリは、rpmによるインストールだと、/usr/share/fpcsrc/packages/base/mysql/ Windowsでは C:\lazarus\fpcsrc\packages\base\mysql\です。

このディレクトリには、mysql.pp, mysql_com.pp そして mysql_version.ppがあります。 テストスクリプトを実行する前に、testdbというデータベースを生成する必要があります。 これをおこなうには、MySQL monitorにrootとして、全権限をもってログインして、次のステートメントを発行します。

CREATE DATABASE testdb;

それから、すべて関連しているユーザが適切なアクセス権を持っていることを確認してください。

GRANT ALL ON testdb TO johnny-user IDENTIFIED BY 'johnnyspassword'; 

ここに、いま実行すべきであるmkdbと呼ばれるスクリプトがあります。

sh ./mkdb

システムが、匿名のユーザにデータベースへのアクセスを許可していないとき、これはたぶん失敗するでしょう。 その場合は、エディタをつかって、MySQLがその行を呼び出すように、スクリプトを変更してください。

mysql -u root -p  ${1-testdb} << EOF >/dev/null

そして、再度mkdbを走らせてみます。プロンプトが出たら、パスワードを入力してください。


幸運にも、あなたは何とかテストデータベースを作成したに違いありません。MySQL monitorにログインしている間、 MySQLステートメントを発行して、テストしてください。

select * from FPdev;

そうすると、FPC開発者のID,ユーザー名、電子メールアドレスが表記されているテーブルを見ることができるでしょう。

今度は、testdb.ppというプログラムを実行させてみてください。 (これは、コンパイルしてください。ほとんど最初は失敗するでしょうけど) 私はこのプログラムはいくつかの理由でmysqlに接続できないことを発見しました。

  • 私の環境(SuSE Linux v9.0)で mysql v4.0.15をインストールしました。パッケージが設計されたバージョン3ではありません。
  • プログラムはデータベースにアクセスするためにユーザー名、パスワードが必要です。
  • コンパイラに、どこにmysqlのライブラリを探せばいいか知らせる必要があります。(もしMySQLの開発ライブラリをインストールしていなければ、今インストールしましょう。)

私はオリジナルを修正したくなかったのでtestdb.ppからtrydb.ppと名づけてコピーを作成しました。オリジナルファイルはCVSを使ったアップデートで修正されてしまうからです。

私はさらに、mysql/ver40/というサブディレクトリの中のファイル群を、 メインのmysql/サブディレクトリに、それぞれのファイルの名前が規則性をたもつように、mysql_v4.pp, mysql_com_v4.pp,mysql_version_v4.ppと名前をかえてコピーしました。

私はtrydb.ppのusesを次のように変更しました。

uses mysql_v4

そして、mysql_v4.ppのusesも次のように変更しました。

uses mysql_com_v4

/etc/fpc.cfgに、自分のライブラリを指すように次の行を加えました。

-Fl/lib;/usr/lib

次のステップは、devel-librariesがあなたのためにリンクとしてインストールされている場合、必要ないかもしれませんが、チェックして損はありません。

私は/usr/libディレクトリのmysqlclintライブラリの本当の名前を調べる必要がありました。そして、私の場合、シェルコマンドを発行しました。

ln -s libmysqlclient.so.12.0.0 lmysqlclient

FPCがライブラリを見つけられるよう、シンボリックリンクを生成するために、です。 また、私は次のようなリンクを作成しました。

ln -s libmysqlclient.so.12.0.0 mysqlclient

そして、同じように色々なほかのディレクトリのリンクを設置しました。 厳密には、必要ではないのですが、このケースではそうしました。

他のユーザーでは、次のようなリンクが必要かもしれません。

ln -s libmysqlclient.so.12.0.0 libmysqlclient.so

私はtrydb.ppをユーザーの詳細を含むように修正しました。最初にhost,user,passwordを定数としてもつように。

const
  host : Pchar= 'localhost';
  user : Pchar= 'myusername';
  passwd: Pchar = 'mypassword';

それでも私は、mysql_connect()をコールしても、まだmysqlに接続できないでいました。しかし、より多くのパラメータを必要とするmysql_real_connect()を使うべきだったのです。さらに物事を複雑にしていたのは、多くのパラメータがversion3(パラメータは7個)とversion4(パラメータは8個)の間で変わっているように思えました。

また、mysql_real_connectを使う前に、mysql_init()を使う必要がありました。 これは、オリジナルのmysql.ppにはありませんでしたが、mysql_v4.ppにはあります。

ここまでで、接続するためのコードは次のようになりました。

{ a few extra variables}
var
  alloc : PMYSQL;
 
{main program fragment}
 
begin
 if paramcount=1 then
   begin
   Dummy:=Paramstr(1)+#0;
   DataBase:=@Dummy[1];
   end;
 
Writeln ('Allocating Space...');
 alloc := mysql_init(PMYSQL(@qmysql));
 Write ('Connecting to MySQL...');
 sock :=  mysql_real_connect(alloc, host, user, passwd, database, 0, nil, 0);
 if sock=Nil then
   begin
   Writeln (stderr,'Couldnt connect to MySQL.');
   Writeln (stderr, 'Error was: ', mysql_error(@qmysql));
   halt(1);
   end;
 Writeln ('Done.');
 Writeln ('Connection data:');
{$ifdef Unix}
 writeln ('Mysql_port      : ',mysql_port);
 writeln ('Mysql_unix_port : ',mysql_unix_port);
{$endif}
 writeln ('Host info       : ',mysql_get_host_info(sock));
 writeln ('Server info     : ',mysql_stat(sock));
 writeln ('Client info     : ',mysql_get_client_info);
 
 Writeln ('Selecting Database ',DataBase,'...');
 if mysql_select_db(sock,DataBase) < 0 then
   begin
   Writeln (stderr,'Couldnt select database ',Database);
   Writeln (stderr,mysql_error(sock));
   halt (1);
   end;
{... as original contents of testdb.pp}

それでは、tyrdb.ppのコンパイルを開始する準備はいいですか?

 fpc trydb

成功しました!それでは実行してみましょう。

 ./trydb

おっ!FPC開発者のリストの一覧を得ることができました!

いくつかの、さらなる改善点があります。 ユーザーに関する詳細のエントリを作る時、あるいは、MySQLのコマンドを双方向にしたいとき、定数よりは変数の方がいいでしょう。そして、いくつかの発行したいSQLコマンドに、結果を返さないコマンドでも(full program listingを見てください)ユーザーの詳細情報をコンソールから入力する部分、プログラムがSQLコマンドがコンソールから入力されるループにはいる部分、結果等について、quitがキーボードから入力されるまで、プリントアウトできるようにしてください。

こちらを見てください。Sample Console Listing

LazarusアプリケーションからMySQLへの接続

このチュートリアルでは、基本的なLazarusコンポーネントのみを使って、LazarusでどのようにMySQLに接続するか、そして簡単なクエリを実行するかを示します。 このとき、Data Aware コンポーネントは使いません。しかし、データベースとインターフェースする原理を解説します。

Lazarusで新しいプロジェクトを生成してください。

Project -> New Project -> Application

自動的に生成されたフォームが現れます。 フォームをスクリーンの半分くらいになるように大きくして、フォームの名前とキャプションを、'TryMySQL'としてください。

コンポーネントパレットのStandardのタブから、3つのエディットボックスを、フォームの左上のほうへ置いてください。そして、それぞれのエディットボックスの真上にラベルを置いてください。 ラベルのキャプションを'Host'としてHostLabel,エディットをHostEditとしてください。 同様に、'UserName'としてUserLabel,UserEditとしてください。 同様に、'Password'としてPasswdLabel,PasswdEditとしてください。 これらのかわりに、LabeledEditコンポーネントをAdditionalタブから使うことができます。

PasswdEditを選択して、PasswordCharプロパティを見つけて、これを * か、他のキャラクタにしてください。そうすることで、画面にパスワードをキーボードから入力したときに表示されないように、かわりに、*の文字を表示するようにします。 それぞれのエディットボックスのTextプロパティが空白であることを確認してください。

ここでさらに、もうひとつエディットボックスとラベルを、フォームの右上に置いてください。 ラベルのCaptionを、'Enter SQL Command'に、NameをCommadEditにしてください。

3つのボタンをフォームに置きます。2つは、EditBoxの下の左のほうへ、もう一つは、右のコマンドボックスの下へ置いてください。

左のボタンは、Caption='Connect to Database'、Name='ConnectButton'、もうひとつは、Caption='Exit'、Name='ExitButton'としてください。右のボタンは Caption='Send Query'、Name='QueryButton'としてください。

大きなメモをフォームの右下に貼り付けて、使えるだけのスペースを使って配置して、'Result'と表示してName='ResultMemo'としてください。テキストがあふれたときに自動的にスクロールバーがつくように、ScrollBars='ssAutoBoth'にしてください。また、WordWrap='True'としてください。

Commonコントロールタブから、ステータスバーをフォームの下に置き、SimpleText='TryMySQL'としてください。

このフォームのスクリーンショットを置いておきます。:Mysql Example Screenshot

これで、必要なイベントハンドラを書くことが出来ます。 左にある3つのエディットボックスはホスト名、ユーザ名、パスワードの入力に使います。これらの3つの入力がきちんと終わったら、Connectボタンをクリックします。このボタンのOnClickイベントハンドラは、先ほどのテキストモードのFPCプログラムの一部とほとんど同じです。

データベースからのレスポンスはPascalのwrite文やwriteln文を使って書かれてはいません。しかし、返答はstringsに変換され、Memoに表示されます。Pascalのwriteとwriteln文は沢山の型変換を実行時に行う能力がある一方、Memoを使ってテキストを出力する際に、明確なデータ型変換をstringの正しい形式にすることが必要です。なので、PChar変数はStrPasを使って変換されなければならず、Integer変数はIntToStrを使って変換されなければなりません。

(訳注:Delphiで慣れた方々には当たり前に思えるかもしれませんが、本来、Pascalでの文字列形式出力はwriteやwritelnを使うものであり、それは、実行時に変数の型を明示しなくても、自動的に適切な文字列として表示することができます。)

文字列はMemoに下記のような関数をつかって表示されます。

procedure ShowString (S : string);
(* display a string in a Memo box *)
begin
       trymysqlForm1.ResultsMemo.Lines.Add (S)
end;

Connectボタンのイベントハンドラは次のようにします。

procedure TtrymysqlForm1.ConnectButtonClick(Sender: TObject);
(* Connect to MySQL using user data from Text entry boxes on Main Form *)
var strg: string;
 
begin
 
 dummy1 :=  trymysqlForm1.HostEdit.text+#0;
 host := @dummy1[1];
 dummy2 := trymysqlForm1.UserEdit.text+#0;
 user := @dummy2[1] ;
 dummy3 := trymysqlForm1.PasswdEdit.text+#0;
 passwd := @dummy3[1] ;
 alloc := mysql_init(PMYSQL(@qmysql));
 sock :=  mysql_real_connect(alloc, host, user, passwd, database, 0, nil, 0);
 if sock=Nil then
   begin
     strg :='Couldnt connect to MySQL.'; showstring (strg);
     Strg :='Error was: '+ StrPas(mysql_error(@qmysql)); showstring (strg);
  end
   else
   begin
     trymysqlForm1.statusBar1.simpletext := 'Connected to MySQL';
     strg := 'Now choosing database : ' + database; showstring (strg);
{$ifdef Unix}
     strg :='Mysql_port      : '+ IntToStr(mysql_port); showstring (strg);
     strg :='Mysql_unix_port : ' + StrPas(mysql_unix_port); showstring (strg);
{$endif}
     Strg :='Host info       : ' + StrPas(mysql_get_host_info(sock));
     showstring (strg);
     Strg :='Server info     : ' + StrPas(mysql_stat(sock)); showstring (strg);
     Strg :='Client info     : ' + Strpas(mysql_get_client_info);  showstring (strg);
 
     trymysqlForm1.statusbar1.simpletext := 'Selecting Database ' + DataBase +'...';
 if mysql_select_db(sock,DataBase) < 0 then
 begin
   strg :='Couldnt select database '+ Database; ShowString (strg);
   Strg := mysql_error(sock); ShowString (strg);
 end
 end;
end;

右のテキストボックスはSQL文を入力するものです。終了のセミコロンなしで良いです。 きちんとしたSQL文を入力して、SendQueryボタンを押すとクエリが実行され、ResultMemoの中に結果が表示されます。

SendQueryのイベントハンドラもFPCのテキストモードの時とほとんど同じですが、表示の際に明示的な型変換をおこなうことを除いてという点は、先ほどの例と同じです。

テキストモードのFPCプログラムと違う点は、エラーが検出されたときにプログラムは停止せず、MySQLもクローズされないところです。そのかわり、制御がメインフォームに戻り、コマンドが再発行できるように修正する機会が与えられます。

アプリケーションは最終的に、Exitボタンがクリックされたときに、MySQLをクローズして終了します。 SendQueryは次のようになっています。

procedure TtrymysqlForm1.QueryButtonClick(Sender: TObject);
var
 dumquery, strg: string;
begin
     dumquery := TrymysqlForm1.CommandEdit.text;
     dumquery := dumquery+#0;
     query := @dumquery[1];
     trymysqlForm1.statusbar1.simpletext := 'Executing query : '+ dumQuery +'...';
     strg := 'Executing query : ' + dumQuery; showstring (strg);
     if (mysql_query(sock,Query) < 0) then
     begin
       Strg :='Query failed '+ StrPas(mysql_error(sock)); showstring (strg);
     end
     else
     begin
       recbuf := mysql_store_result(sock);
       if RecBuf=Nil then
       begin
         Strg :='Query returned nil result.'; showstring (strg);
       end
       else
       begin
         strg :='Number of records returned  : ' + IntToStr(mysql_num_rows (recbuf));
         Showstring (strg);
         Strg :='Number of fields per record : ' + IntToStr(mysql_num_fields(recbuf));
         showstring (strg);
         rowbuf := mysql_fetch_row(recbuf);
         while (rowbuf <>nil) do
         begin
              Strg :='(Id: '+ rowbuf[0]+', Name: ' + rowbuf[1]+ ', Email : ' +
               rowbuf[2] +')';
              showstring (strg);
              rowbuf := mysql_fetch_row(recbuf);
         end;
       end;
     end;
end;

プロジェクトを保存して、メニューからRun -> Runを選んでください。

MySQLのソースコードをダウンロードする

全ソースコードは次からダウンロードできます。Sample Source Code

Lazarus と PostGreSQL

これは、Lazarus 0.9.12以降と、PostGresSQLデータベースを、ローカル、リモートの両方でTPQConnectionを使って接続するためのとても短いチュートリアルです。

インストールを正しくおこなったの後で、次のステップをやってみてください。

  • SQLdbタブから、PQConnectionを置く
  • SQLdbタブから、SQLQueryを置く
  • SQLdbタブから、SQLTransactionを置く
  • DataAccessタブから、DataSourceを置く
  • DataControlsタブから、DBGridを置く
  • PQConnectionのプロパティを適切に設定してください。
    • transaction propertyに、SQLTransactionオブジェクトを参照させる。
    • Database name
    • HostName
    • UserName + password
  • SQLTransactionが自動的にPQConnectionを示すように変更されたとこに注意してください。
  • SQLQueryのプロパティを適切に埋めてください。
    • transaction プロパティに適切なオブジェクト
    • database プロパティに適切なオブジェクト
    • SQL (たとえば、'select * from anytable' などとしてください。)
  • DataSourceオブジェクトのDataSetプロパティに、SQLQueryオブジェクトを指定してください。
  • DBGridオブジェクトのDataSourceプロパティにDataSourceオブジェクトを設定してください。

すべてをconnectedとactiveにすると、設計時においても、DBGridに表示がされます。 TDBTextとTDBEditは、私には、ただ値を表示するだけのように見えます。

To change contents in the database, I called the DB Engine direct with the following code: データベースの内容を更新するには、私は次のようにDBエンジンをダイレクトに呼び出します。

 try
   sql:= 'UPDATE table SET setting=1';
   PQDataBase.Connected:=True;
   PQDataBase.ExecuteDirect('Begin Work;');
   PQDataBase.ExecuteDirect(sql);
   PQDataBase.ExecuteDirect('Commit Work;');
   PQDataBase.Connected:=False;
 except
   on E : EDatabaseError do
     MemoLog.Append('DB ERROR:'+sql+chr(13)+chr(10)+E.ClassName+chr(13)+chr(10)+E.Message);
   on E : Exception do
     MemoLog.Append('ERROR:'+sql+chr(13)+chr(10)+E.ClassName+chr(13)+chr(10)+E.Message);
 end;


  • ノート:
    • Lazarus 0.9.12 + PGSQL 8.3.1にて、Windowsでテストしました。
    • Lazarus 0.9.12 and PGSQL 8.0.xで、Linuxでテストしました。


  • インストレーションとエラー:
    • Lazarus 0.9.12のテストバージョン では、"text" と "numeric" の型にバグがあります。
    • 固定長のキャラクタと、intとfloat8では、私は問題なく使えました。
    • 時々Lazarusを再起動することでくだらないエラーを解決できた
    • いくつかのエラーの後で、トランザクションがアクティブのまま残り、手動でデアクティベートしなくてはならなかった。
    • Lazarusによって行われた変更は、もちろん、トランザクションがコミットされるまでは見ることができません。(訳注:他のトランザクションでは、ということ)
    • IDEのデバッガは(少なくともWindowsにおいては)バグがあるようです。時々IDEの外で走らせるとエラーの発生を見つけるのに役立ちます。
    • Linuxでは、特定のエラーメッセージがコンソールに出力されることがあります。--もし、コマンドラインで走らせているなら、時々デバッグに役立つ情報があります。
    • このようなエラーが発生することがあります。: "Can not load Postgresql client. Is it installed (libpq.so) ?"
      • PostgreSQLをインストールした所から、libpq*を探して、パスに加えて下さい。
      • Linuxでは、pathにlibpq.soファイルを、/etc/fpc.cfgの中のライブラリセクションに加えてください。たとえば、次のように:-Fl/usr/local/pgsql/lib
      • Windowsでは、これらのライブラリを、環境変数のパスのどこにでも追加してください。また、プロジェクトディレクトリに加えてもかまいません。
      • 私は、すべてのDLLを自分のパソコンのC:\Program Files\PostgreSQL\8.1\bin などに入れて、パスを通しています。

Lazarus と SQLite

Luiz Américo による

イントロダクション

TSQLLiteDatasetとTSQLLite3DatasetはTDatasetの派生クラスで、2.8.xと3.2.xのSQLLiteデータベースにアクセスします。下記は主な特徴と欠点です。

特徴:

  • 自由度が高い: データベースはシンプルなテーブルレイアウトでも、複雑なSQLを使ってもよいので、プログラマは、SQLを使っても良いし、使わなくても良い。
  • 自動データ更新: SQL文でデータベースを手動でアップデートする必要はありません。1つの命令で更新ができます。
  • 高速: メモリにデータをキャッシュするため、データセットを高速にブラウズします。
  • サーバーインストール、設定が不要:SQLLiteダイナミックライブラリと一緒に配布するだけです。

欠点

  • 外部ファイルを必要とします。(sqlite library)

要求事項

  • sqlite2のためには:
    • fpc 2.0.0
    • Lazarus 0.9.10
    • sqlite runtime library 2.8.15 以上(www.sqlite.orgから)
  • sqlite3のためには:
    • fpc 2.0.2
    • Lazarus 0.9.11 (svn revision 8443 以上)
    • sqlite runtime library 3.2.1 以上 (www.sqlite.orgから)

Lazarusのプロジェクトを作る前に、次の事を確認してください。:

  • SQLLiteライブラリがシステムパスか、実行できるディレクトリにあるかどうか。
  • Linuxでは、cmemを メインプログラムのusesの最初のユニットにしているかどうか

使い方 (基本)

/components/sqlite にあるパッケージをインストールしてください。(ここにその方法があります。) 設計時に下記のプロパティをセットして下さい。

  • FileName: sqliteファイルへのパス[必須]
  • TableName: sql文で使うテーブル名[必須]
  • Sql: SQLのSELECT文 [必要に応じて]

テーブルを作成する(Dataset)

コンポーネントアイコンをダブルクックするか、右マウスボタンのクリックで現れるポップアップメニューで、'Create Table'を選択します。

簡単な説明のあるテーブルエディタが表示されます。

 下記はTSqliteDatasetとTSqlite3Datasetでサポートされているすべてのフィールドの型です。
 Integer
 AutoInc
 String
 Memo
 Bool 
 Float
 Word
 DateTime
 Date
 Time
 LargeInt
 Currency
 

データを取得する

テーブルを生成した後か、以前作ったテーブルで作業する場合、Open手続きでデータセットを開いて下さい。 SQLプロパティがセットしていない場合、すべてのフィールドのすべてのレコードを取得するためには、次のような1文をSQLにセットします。:

 SQL:='Select * from TABLENAME'; 

データファイル上に変更を保存する

ApplyUpdates関数を使うために, データセットは主キーの条件にあうための、少なくとも1つのフィールドを持っていなければなりません。(つまり、ユニークであって、NULLではない、という条件です。)

更新をおこなうために2つの方法が可能です。

  • PrimaryKeyプロパティに主キーになっているフィールド名を指定する。
  • AutoIncフィールドを加える。(これはTSqliteDatasetが自動的にそれを主キーとしてみなすので簡単です。)

もし、2つの条件のうち、1つをセットしたら、次のように呼び出すだけです。

 ApplyUpdates;

追記1: もし、両方の条件がセットされたら、主キーによるフィールドが更新のために使われます。

追記2:フィールドに主キーを設定することは、ApplyUpdateがコールされたときに、主キーによってデータをみつけられなくてはいけません。 ですから、選択されたフィールドは、 Nullを含まないことや、一意であることを確認してください。

注意事項

  • 10000レコードまではテストして、上手く動きますが、TSqliteDatasetはすべてのデータをメモリ上に置くため、必要なデータのみ受け取るようにしてください。(特にMemoフィールドなどに注意).
  • 同じデータファイルに、いくつかのテーブル、データセットを持たせることができます。
  • いくつかのデータセット(違うフィールドの組み合わせの)を同じテーブルから作ることができます。
  • SQLでWHERE文を使ってデータを選別することが可能です。クローズして再オープンする(あるいは、RefechDataメソッドをつかう)ことができます。この場合、並び順やフィールドの数は同じでなくてはなりません。
  • 複数のテーブルからaliasesやjoin,viewsなどを使って複雑なSQL文を使うことが可能です。(しかし、これらは同じデータファイルになくてはなりません。)しかしこの場合、ApplyUpdateは動作しません。もし複雑なクエリをつかって、データファイルに更新を加えたければ私(Luiz Américo)にメールしてください。そうすれば、どういうふうにおこなうか、ヒントをお伝えすることができます。
  • TSqliteDatasetで生成されていない、そして、開いていないsqlite2.xのデータファイルにファイル名を設定するとき、一部のフィールドが正しい型を検出することが、許可されていません。これらは、stringフィールドとして扱われます。

一般的なサンプルが、fpc/fcl/db/sqlite CVSディレクトリにあります。

Luiz Américo pascalive(at)bol(dot)com(dot)br

Lazarus と MSSQL

これはZeoslib (latest cvs)でおこなっています。ページの最後のリンクを見てください。

Lazarus と Interbase / Firebird

Install Packagesを見て下さい。このページにはどのようにIBやFBサーバーと接続するか、最初の小さいサンプルと説明があります。

この作業も最新のZeoslibにあります。

FBLib Firebird ライブラリ

[1] はDelphi/Kylix、FreePascalとLazarusからFirebirdリレーショナルデータベースに直接アクセスする、(DataAwareではない)オープンソースライブラリです。

現在、次のような特徴があります。

  • Firebird 1.0.x 1.5.x Classic SuperServer に直接接続します。
  • マルチプラットホームです。 [Win32,Gnu/Linux,FreeBSD)
  • 自動的にクライアントライブラリを選択します。'fbclient' または 'gds32'
  • パラメータ型クエリのサポート
  • SQL Dialect 1/3をサポート
  • LGPL ライセンス
  • メタデータの抽出
  • シンプルなスクリプトパーサ
  • 実行ファイルは100-150 KB しか増えません。
  • BLOB フィールドをサポートします。
  • HTML SQL Scriptへデータを出力します。
  • サービスマネージャ (backup,restore,gfix...)
  • イベントアラータ

文書はここからダウンロードできます。FBLibのWebサイト.

Lazarus と dBase

Tony Maro

このページも訪れるとよいでしょう。TDbf Tutorial page

FPCはDelphiのTTableコンポーネントとにた機能をもつ、"TDbf"(TDbf Website)と呼ばれる、シンプルなデータベースコンポーネントを含んでいます。 これは、基本的なdBaseファイルの機能の基本的なサブセットをサポートしています。これは、デフォルトではインストールされませんので、最初にすることはLazarusパッケージを"lazarus/components/tdbf" からインストールして、Lazarus IDEをビルドすることです。そうすれば、コンポーネントパレットにTDatasourceの次に現れます。

TDbfコンポーネントは他のデータベースコンポーネントに対して、次のような利点があります。すなわち、どんな種類のランタイムデータベースエンジンも必要としないことです。しかしながら、大きいデータベースをもつアプリケーションには最適ではありません。

これを使うのは非常に簡単です。単に、フォームの上にTDbfをドロップしておいてください。ランタイムパスにデータベースファイルを置く場所を指定します。テーブル名をセットします。そして、TDatasourceコンポーネントにリンクします。

しかしながら、もうちょっと努力して本格的な機能が求められます。テーブルがすでに存在しない場合、テーブルデザイナに相当するものがなければ(私はしりませんが)、プログラムからそれをつくる必要があります。

存在しないテーブルを開こうとすると、エラーが生成されます。テーブルはプログラムから、ランタイムパスとテーブル名をセットしたコンポーネントを通して、作ることができます。

たとえば、あなたのDVDコレクションを記録するために"dvds"というテーブルを作る場合、フォームにTDbfコンポーネントをドロップして、ランタイムパスと"dvds"と名づけたテーブル名を設定してください

結果ファイルは"dvds.dbf"となります。

コードでおこなう場合次のようなコードを入れてください。

   Dbf1.FilePathFull := '/path/to/my/database';
   Dbf1.TableName := 'dvds';
   With Dbf1.FieldDefs do begin
       Add('Name', ftString, 80, True);
       Add('Description', ftMemo, 0, False);
       Add('Rating', ftString, 5, False);
   end;
   Dbf1.CreateTable;

このプログラムを走らせると、あなた用のDVDコレクションテーブルが作られます。その後、すべてのdata awareコンポーネントがTDatasourceを通してリンクされ、データに簡単にアクセスできるようになります。

インデックスを付加することは、典型的なTTableとはちょっと異なっています。データベースは開いていなくてはなりません。インデックスをリビルドするのと同じメソッドを使います。

例えば:

   Dbf1.Exclusive := True;
   Dbf1.Open;
   Dbf1.AddIndex('dvdsname','Name',[ixPrimary, ixUnique, ixCaseInsensitive]);
   Dbf1.AddIndex('rating.ndx', 'Rating', [ixCaseInsensitive]);
   Dbf1.Close;

最初のインデックス(プライマリインデックス)は、"dvdname.mdx"というファイルにはいっており、2番目のインデックスは、"rating.ndx"というファイルにはいっています。複数のテーブルがあるデータベースでは、同じファイル名を使わないよう注意を払ってください。

今後、もっと詳細な例を作りたいと思っています。願わくば、昔Delphiに馴染んだ方々に立ち上がっていただき、Lazarusでデータベースのプログラムを作るきっかけになってほしいと思っています。

関連のある記事

https://trac.synsport.com:8000/index.php/pdo/wiki (username/password is guest/guest)

Contributors and Changes

This page has been converted from the epikwiki version.