mysql

From Lazarus wiki
Revision as of 17:23, 8 October 2011 by Chronos (talk | contribs) (category)
Jump to navigationJump to search

English (en) | Español (es) |

Overview

You can use Free Pascal to access a MySQL database server from Linux. (for more info on MySQL, see their home page.)

Interfacing is very easy, all you need to do is compile some units, and use these units in your program. You need to specify the place of the MySQL client Library (libmysqlclient when compiling, and that is it. the provided units take care of the rest.

Provided units and programs

The packages provides 3 units, of which normally only the first is needed:

  • mysql the main mysql unit.
  • mysql version provides access to the version number of the mysql library.
  • mysql com contains some internal routines of mysql, should normally not be used unless you want access to some internal types.

The same units exist for versions 3.22 and 4.00 of mysql as well, in subdirecties. The default supported version is version 3.23.

The test program is called testdb.

MySQL licensing

Before a significant MySQL deployment, don't forget to read its license

Installation

The mysql interface is distributed with the Free Pascal packages, and come with the compiler distribution: Normally no action should be taken to work with MySQL.

In case you want to modify and compile the units yourself, the mysql sources are in the packages directory: packages/mysql

This directory contains the units, a test program and a makefile. cd to the directory and type

make

This should compile the units. If compilation was succesful, you can install with

make install

You can then test the program by running

make test

This will:

  • Run a script to create a table in a database, and fill it with some data. (the mysql program should be in your PATH for this) . By default, the used database is testdb.
  • Run the testprogram testdb
  • Run a shell script again to remove the created table.

You will see a lot of messages on your screen, giving you feedback and results. If something went wrong, make will inform you of this.

Future plans

The interface to mysql is a pure translation of the mysql C header files. This means that the used functions are rather un-pascalish. It would be great to have an OOP interface for it, A la Delphi. This interface is being worked on.

Go to back Packages List