Recent

Author Topic: User guide about postgres.ppu, postgres3.ppu, or postgres3dyn.ppu  (Read 5301 times)

pregnolato

  • Newbie
  • Posts: 4
Hi guys.

I am using FPC 3.0.0 and I am looking for some user guide about the unit files postgres.ppu, postgres3.ppu, or postgres3dyn.ppu.  Is  there someone in this group  that already used these ppu files and can help me?

I need to connect in a Posgresql database, and do some queries, truncate table, inserts, etc.

Thank's

Valerio Pregnolato

JD

  • Hero Member
  • *****
  • Posts: 1848
Re: User guide about postgres.ppu, postgres3.ppu, or postgres3dyn.ppu
« Reply #1 on: August 23, 2016, 09:08:44 pm »

I need to connect in a Posgresql database, and do some queries, truncate table, inserts, etc.

Thank's

Valerio Pregnolato

Read these forum topics
a) http://forum.lazarus.freepascal.org/index.php/topic,31964.msg205610.html#msg205610
b) http://forum.lazarus.freepascal.org/index.php/topic,32252.msg207766.html#msg207766

You can also use the standard SQLdb components to connect with a PostgreSQL database. The Lazarus Wiki has detailed ttutorials on using SQLdb.

JD
« Last Edit: August 23, 2016, 09:12:18 pm by JD »
Windows - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe),
Linux Mint - Lazarus 2.1/FPC 3.2 (built using fpcupdeluxe)

mORMot; Zeos 8; SQLite, PostgreSQL & MariaDB; VirtualTreeView

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: User guide about postgres.ppu, postgres3.ppu, or postgres3dyn.ppu
« Reply #2 on: August 24, 2016, 05:14:10 am »
I am using FPC 3.0.0 and I am looking for some user guide about the unit files postgres.ppu, postgres3.ppu, or postgres3dyn.ppu.  Is  there someone in this group  that already used these ppu files and can help me?

I need to connect in a Posgresql database, and do some queries, truncate table, inserts, etc.
We don't usually use those low level units which is usually converted from the C header counterpart. Use SQLdb instead (search wiki for tutorial) or ZEOS if you're already familiar with it from Delphi. The high level classes and methods are database agnostics, you can switch between database backend in a single assignment statement. The queries are still database specific, though.

pregnolato

  • Newbie
  • Posts: 4
Re: Using FPC 3.0.0 with Postgresql 9.3 (sqldb.ppu)
« Reply #3 on: August 24, 2016, 10:13:21 pm »
Hi guys.

JD, I tried to use sqldb.ppu with Postgresql version 9.3.

see part of my code:

uses
    sqldb,
    ibconnection;
var
    pgConnection     : tSQLConnection;
    pgTransaction    : tSQLTransaction;
    pgQuery          : tSQLQuery;
begin
    pgConnection := tSQLConnection.create(nil);
    try
        pgConnection.hostName     := '130.1.0.100:5432;
        pgConnection.databaseName := 'wgusers';
        pgConnection.userName     := 'lion';
        pgConnection.password     := 'xyz123';
        pgConnection.charSet      := '1252';
        pgTransaction := tSQLTransaction.create(pgConnection);
        pgTransaction.database := pgConnection;
        pgConnection.connected := TRUE;
        pgQuery := tSQLQuery.create(pgConnection);
        pgQuery.database := pgConnection;
        pgQuery.transaction := pgTransaction;
        pgQuery.SQL.text := 'select DISPLAY_NAME from public.ad;';
        pgQuery.open;
        while not pgQuery.EOF do begin
            writeln(pgQuery.fieldByName('DISPLAY_NAME').asString);
            pgQuery.next;
        end;
        pgQuery.close;
    finally;
        pgCOnnection.free;
    end;
end.

When this program execute line "pgQuery.open" I am getting the error below:

        An unhandled exception occurred at $00433F7F:
        EAbstractError: Abstract method called
              $00433F7F
              $00433D11
              $0043529E
              $0044A93B
              $004351BB

Could you please help me about this error?

by chance anybody in this forum have some example to show to me?
« Last Edit: August 24, 2016, 10:27:37 pm by pregnolato »

sky_khan

  • Guest
Re: User guide about postgres.ppu, postgres3.ppu, or postgres3dyn.ppu
« Reply #4 on: August 24, 2016, 11:01:32 pm »
TSQLConnection is base class for database connections and not usable itself. You should use TPQConnection for Postgresql instead of TSQLConnection.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: User guide about postgres.ppu, postgres3.ppu, or postgres3dyn.ppu
« Reply #5 on: August 24, 2016, 11:17:57 pm »
TSQLConnection is base class for database connections and not usable itself. You should use TPQConnection for Postgresql instead of TSQLConnection.
Or use TSQLConnector, which is covered in SQLdb tutorial 3, which I believe you haven't read.

sky_khan

  • Guest
Re: User guide about postgres.ppu, postgres3.ppu, or postgres3dyn.ppu
« Reply #6 on: August 25, 2016, 12:31:16 am »
@Leledumbo
Is my answer wrong ?
Does TPQConnection work and connects Postgresql ? I believe it does. So?

I'm becoming sick of this. People, like you, tries to correct my answers which are not wrong in the first place
You could say "You may use TSQLConnector if you want to connect multiple databases" or something by addressing original poster but no.
You had to ask if i read tutorial. I have not and no intent to, if you reaally have to know.

I'm an old Delphi programmer who knows Lazarus a bit and trying to help newbies here on my spare time.
Besides, my English is far from perfect and its kind of difficult to express myself right except on technical topics.
My writing sucks bad, very bad. e.g I had to spent about 20 minutes to be able to write this post kind of suck. Do you understand ?

So, thanks but no thanks.  I dont need your education.
And bye.
You just lost me.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8747
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: User guide about postgres.ppu, postgres3.ppu, or postgres3dyn.ppu
« Reply #7 on: August 25, 2016, 07:20:59 am »
@Leledumbo
Is my answer wrong ?
Does TPQConnection work and connects Postgresql ? I believe it does. So?

I'm becoming sick of this. People, like you, tries to correct my answers which are not wrong in the first place
You could say "You may use TSQLConnector if you want to connect multiple databases" or something by addressing original poster but no.
You had to ask if i read tutorial. I have not and no intent to, if you reaally have to know.

I'm an old Delphi programmer who knows Lazarus a bit and trying to help newbies here on my spare time.
Besides, my English is far from perfect and its kind of difficult to express myself right except on technical topics.
My writing sucks bad, very bad. e.g I had to spent about 20 minutes to be able to write this post kind of suck. Do you understand ?

So, thanks but no thanks.  I dont need your education.
And bye.
You just lost me.
Sorry, I was pointing to pregnolato, I give alternative to your answer.

LacaK

  • Hero Member
  • *****
  • Posts: 691
Re: User guide about postgres.ppu, postgres3.ppu, or postgres3dyn.ppu
« Reply #8 on: August 25, 2016, 11:31:52 am »
I'm becoming sick of this. People, like you, tries to correct my answers which are not wrong in the first place
:D be in peace. Your answer was perfect.

pregnolato

  • Newbie
  • Posts: 4
Re: Using FPC 3.0.0 with Postgresql 9.3 (sqldb.ppu)
« Reply #9 on: August 25, 2016, 05:41:22 pm »
I am using a FPC 3.0.0 and  also I have instaled pgAdmin III version 1.22

Just for test,  I copied all DLL from "C:\Program Files (x86)\pgAdmin III\1.22" to "C:\FPC\3.0.0\bin\i386-win32"

I tried change my code to use TPQConnection, as sugested our friend SkyKhan.

now my dirt source code is:

program adtopg;
uses  sysUtils, classes, sqldb, db, pqconnection, bufdataset, sqlscript;
var
    pgConnection     : TPQConnection;
    pgTransaction    : tSQLTransaction;
    pgQuery          : tSQLQuery;
begin
    pgConnection := TPQConnection.create(Nil);
    try
        pgConnection.hostName     := '130.1.0.100:5432';
        pgConnection.databaseName := 'wgusers';
        pgConnection.userName     := 'lion';
        pgConnection.password     := 'xyz123';
        pgConnection.charSet      := 'utf-8';
        pgTransaction := tSQLTransaction.create(pgConnection);
        pgConnection.transaction := pgTransaction;
        pgConnection.open;
        pgTransaction.database := pgConnection;
        pgTransaction.startTransaction;
        {pgConnection.connected := TRUE;}
        pgQuery := tSQLQuery.create(pgConnection);
        pgQuery.database := pgConnection;
        pgQuery.transaction := pgTransaction;
        pgQuery.SQL.text := 'select DISPLAY_NAME from public.ad;';
        pgQuery.open;
        while not pgQuery.EOF do begin
            writeln(pgQuery.fieldByName('DISPLAY_NAME').asString);
            pgQuery.next;
        end;
    finally;
        pgQuery.close;
    end;
    pgConnection.free;
end.

... AND in the line "pgConnection.open;"  I am getting ERROR:

The ordinal 2497 could not be located in the dynamic link library C:\FPC\3.0.0\bin\i386-win32\libpq.dll.

I try to find some information about this error in the web, but I did not found.
Is  someone  got this error?
How  could I fix it?


Thanks,

Valerio Pregnolato from Brazil.
« Last Edit: August 25, 2016, 05:42:57 pm by pregnolato »

pregnolato

  • Newbie
  • Posts: 4
Re: User guide about postgres.ppu, postgres3.ppu, or postgres3dyn.ppu
« Reply #10 on: August 29, 2016, 07:24:15 pm »
Hi friends.

I solved this error just  changing DLL files.

the correct versions are:

libeay32.dll (version 0.9.8.12)
libpq.dll (version 8.4.0.9159)
msvcr90.dll (version 9.00.30.729.1)
ssleay32.dll (version 0.9.8.12)


 

TinyPortal © 2005-2018