Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-02

Communication with PostgreSQL

5 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Johann Spies

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/

which compiles if I use make.

But when I try to use either of those programs in Lazarus or try to compile it with fpc from the command line I get the message

Fatal: Can't find unit postgres used by testpg

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. When I put that in the above file in Lazarus I get

Fatal: Can't find unit contnrs used by Masks

I have also tried to add

/usr/share/fpcsrc/2.6.0/packages/postgres
/usr/lib/fpc/2.6.0/units/x86_64-linux
/usr/lib/fpc/2.6.0/units/x86_64-linux/postgres
/usr/share/fpcsrc/2.6.0/packages/postgres

to the environment options/path editor of Lazarus, but that did not make any difference.

How do I go forward from here?

Regards
Johann

Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130207/d8f35f4a/attachment.html>

Reply by email

Reinier Olislagers
to Johann Spies
Johann Spies wrote 12 lines
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

Reply by email

leledumbo
to Johann Spies: Long ago I have worked with Turbo Pascal 7 in a DOS environment. Now after many years I…

Looks like your fpc.cfg isn't setup well, could you post the content here? It should be located in /etc, if none exists, then you definitely miss one. Create the default file with fpcmkcfg program (comes with fpc, so you probably already have it) then move to /etc. Edit (or add) -Fu lines to point to your COMPILED units directory. If you install FPC from repository, this should normally be: -Fu/usr/lib/fpc/<fpc version>/units/<your arch-os pair>/* (-Fu supports wildcard).

View this message in context: http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-Communication-with-PostgreSQL-tp4029138p4029141.html Sent from the Free Pascal - Lazarus mailing list .

Reply by email

Johann Spies
to leledumbo

@Reinier:

Thanks for the advice. I will try sqldb/Tpqconnection.

@leledumbo_coo l:

I have done that previously. After I sent my first message I also found that neither fpc nor lazarus could work with the postgres library reporting that it could not find the unit 'system'.

So I rebuild all the debian packages and reinstalled them. I also used the Lazarus tool to recompile the ide with packages.

After all that I could compile the two test programs in Lazarus. When running them, the first one succeeded, but I could not get the second one to work well.

I am now going to try out the sqldb/Tpqconnection road...

Regards
Johann

Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130207/c3f3298c/attachment.html>

Reply by email

Chavoux Luyt
to Johann Spies

Hi Johann

I wasn't going to comment since this is for a command-line program. But what version of Lazarus do you have (and on which version of Debian)? I ask because the Debian Lazarus packages are notoriously out of date. (E.g. Lazarus 1.0+ has been out for a while, but not available from the main Debian repositories for my "Debian stable" - based distro). I had to install the .deb package from the Lazarus web site instead.

Cheers
Chavoux
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130207/1b168e5f/attachment.html>

Reply by email