The mysql unit.
Free Pascal interface to MySQL
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. (View interface.)
- mysql version provides access to the version number of the mysql library. (View interface).
- mysql com contains some internal routines of mysql, should normally not be used unless you want access to some internal types. (View interface).
The test program is called testdb.
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/base/mysqlThis directory contains the units, a test program and a makefile. cd to the directory and type
makeThis should compile the units. If compilation was succesful, you can install with
make installYou can then test the program by running
make testThis 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.
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.
Finally
If you have found a bug, or if you have made some functions to interface these units in a more pascal-like fashion, feel free to contact me at michael.vancanneyt@freepascal.org
Back to packages
