The postgres unit.

Free Pascal interface to PostGreSQL

Overview

You can use Free Pascal to access a PostGreSQL database server from Linux. (for more info on PostGreSQL, 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 PostGreSQL client Library (libpq) when compiling, and that is it. the provided units take care of the rest.

The main unit is called postgres, normally this is the only unit you must include in your uses clause. (view interface)

Requirements

You need at least version 0.99.5 of Free Pascal. The headers are translated from PostGreSQL version 6.3.1. Using an earlier version may not work.

Installation

The prostgres unit comes with the Free Pascal packages, and is distributed together with the compiler. This contains a directory postgres with the units, a test program and a makefile. cd to the directory and edit the Makefile to set the variables for your system. You must provide only 1 thing:
  1. The directory where the libpq library resides, usually /usr/local/pgsql/lib
Typing
make
Should compile the units and the program. If compilation was succesfull, you can install with
make install
(Remember to set the directory where the units should be installed.)

You can then test the program by running

make test
This will: 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 PostGreSQL is a pure translation of the PostGreSQL 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 page.