[Lazarus] Communication with PostgreSQL

Reinier Olislagers reinierolislagers at gmail.com
Thu Feb 7 12:36:33 CET 2013


On 7-2-2013 12:13, Johann Spies wrote:
> Long ago I have worked with Turbo Pascal 7 in a DOS environment.
> 
> Now after many years I want to use Pascal again.  I have installed
> Lazarus on my Debian system and had some success with initial short
> routines trying to refresh my old skills and trying to cope with all the
> changes.
> 
> I want to develop a command line program which can communicate with a
> PostgreSQL server.
> There are two example programs with a Makefile in 
> /usr/share/doc/fp-units-db/2.6.0/examples/postgres/ and
> /usr/share/fpcsrc/2.6.0/packages/postgres/examples/
<snip>
> I see there is a button for database connections when developing
> gui-products and that it does not use the postgres unit but rather
> something like pqconnection. 
<snip>
> How do I go forward from here?

Regarding your choice of library:

I would recommend to use sqldb/Tpqconnection (the library Lazarus uses
for its GUI DB connectors). It's higher level than the low level
database-specific code and probably easier to use.

Switching to other dbs will also be much easier ;)

This library can be used in FPC as well as Lazarus progs.

See e.g.
http://wiki.lazarus.freepascal.org/SQLdb_Tutorial1
http://wiki.lazarus.freepascal.org/SQLdb_Tutorial2
http://wiki.lazarus.freepascal.org/SQLdb_Tutorial3
as well as the recently improved documentation e.g. at
http://www.freepascal.org/docs-html/fcl/sqldb/index.html

Regards,
Reinier




More information about the Lazarus mailing list