Sign in Join

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

Mailing lists / lazarus / 2011-11

Postgres Cannot connect

17 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

Tom Russell

Hi,

I am using Postgres on OSX Snow Leopard. I have it installed and have used it with other languages and tools, etc but I cannot seem to figure out how to set the path to the dylib for it from my lazarus program.

When I try setting the connection property to true it states it cannot find the file and asks if Postgres is installed.

Is there something I need to set some place so that it knows where to look in order to connect?

Thanks,

Tom

Reply by email

silvioprog
to Tom Russell

2011/11/21 Tom Russell :

Show quoted text 16 lines
Hi, I am using Postgres on OSX Snow Leopard. I have it installed and have used it with other languages and tools, etc but I cannot seem to figure out how to set the path to the dylib for it from my lazarus program. When I try setting the connection property to true it states it cannot find the file and asks if Postgres is installed. Is there something I need to set some place so that it knows where to look in order to connect? Thanks, Tom

With SQLConnector, set the property "ConnectorType" to 'postgresql', and declare the unit PQConnection in the uses clause.

Works fine to me in openSUSE, Mint and Windows 7 (*).

(*) To run my project in Win7:

C:\Users\MYUSER>copy "C:\Program Files (x86)\PostgreSQL\8.4\bin\*.dll" "C:\fo lder\of\my\project".

To run my project within the IDE too: "C:\Program Files (x86)\PostgreSQL\8.4\bin\*.dll" "C:\lazarus".

Silvio Cl?cio =============================================== Blog - <silvioprog.com.br> Twitter - <twitter.com/silvioprog> Facebook - <facebook.com/silvioprog> LazSolutions - <code.google.com/p/lazsolutions> Lazarus-BR - <groups.google.com.br/group/lazarus-br?hl=pt-BR> =============================================== ? ?* Conhe?a nosso canal IRC sobre Lazarus: #lazarus-br * ===============================================

Reply by email

Tom Russell
to silvioprog

I tried this but it still cannot find the files I need to connect to postgres.

silvioprog wrote 49 lines
2011/11/21 Tom Russell : > Hi, > > I am using Postgres on OSX Snow Leopard. I have it installed and have > used it with other languages and tools, etc but I cannot seem to > figure out how to set the path to the dylib for it from my lazarus > program. > > When I try setting the connection property to true it states it cannot > find the file and asks if Postgres is installed. > > Is there something I need to set some place so that it knows where to > look in order to connect? > > Thanks, > > Tom With SQLConnector, set the property "ConnectorType" to 'postgresql', and declare the unit PQConnection in the uses clause. Works fine to me in openSUSE, Mint and Windows 7 (*). (*) To run my project in Win7: C:\Users\MYUSER>copy "C:\Program Files (x86)\PostgreSQL\8.4\bin\*.dll" "C:\fo lder\of\my\project". To run my project within the IDE too: "C:\Program Files (x86)\PostgreSQL\8.4\bin\*.dll" "C:\lazarus". -- Silvio Cl?cio =============================================== Blog - <silvioprog.com.br> Twitter - <twitter.com/silvioprog> Facebook - <facebook.com/silvioprog> LazSolutions - <code.google.com/p/lazsolutions> Lazarus-BR - <groups.google.com.br/group/lazarus-br?hl=pt-BR> =============================================== ? ?* Conhe?a nosso canal IRC sobre Lazarus: #lazarus-br * =============================================== -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Tom Russell
to Joost van der Sluis

Using FPC 2.44 and the file it cannot find is libpq.dylib which is in Library/PostGreSQL/9.1/Bin

Thanks,

Tom

Joost van der Sluis wrote 18 lines
On Mon, 2011-11-21 at 11:01 -0500, Tom Russell wrote: > I tried this but it still cannot find the files I need to connect to postgres. > >> When I try setting the connection property to true it states it cannot > >> find the file and asks if Postgres is installed. Can you tell us what 'the' file is? (And your Free Pascal version) -- My Lazarus blog: http://www.lazarussupport.com/lazarus/weblog -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Joost van der Sluis
to Tom Russell
Tom Russell wrote
Using FPC 2.44 and the file it cannot find is libpq.dylib which is in Library/PostGreSQL/9.1/Bin

My guess is that that path is not in you library-search path. Try 'ld --verbose' on the commandline. See which search-directories are used, and add a symlink in one of them.

Or you can add the postgres3dyn unit to your uses-list, and call 'InitialisePostgres3('Library/PostGreSQL/9.1/Bin/libpq.dylib');' before you do anything db-related.

Reply by email

Tom Russell
to Joost van der Sluis

Weird that command is said that its unknown. Is that for OSX or linux?

Thanks , Ill try the other option as well.

Joost van der Sluis wrote 22 lines
On Mon, 2011-11-21 at 11:20 -0500, Tom Russell wrote: > Using FPC 2.44 and the file it cannot find is libpq.dylib which is in > Library/PostGreSQL/9.1/Bin My guess is that that path is not in you library-search path. Try 'ld --verbose' on the commandline. See which search-directories are used, and add a symlink in one of them. Or you can add the postgres3dyn unit to your uses-list, and call 'InitialisePostgres3('Library/PostGreSQL/9.1/Bin/libpq.dylib');' before you do anything db-related. -- My Lazarus blog: http://www.lazarussupport.com/lazarus/weblog -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Tom Russell
to Tom Russell

I tried adding the unti to my uses as well as the snippet you gave but it says its the wrong number of parameters? I dont see where that even accepts any really.

Or Im confused?

Thanks,

Tom

Tom Russell wrote 30 lines
Weird that command is said that its unknown. Is that for OSX or linux? Thanks , Ill try the other option as well. On Mon, Nov 21, 2011 at 12:02 PM, Joost van der Sluis wrote: > On Mon, 2011-11-21 at 11:20 -0500, Tom Russell wrote: >> Using FPC 2.44 and the file it cannot find is libpq.dylib which is in >> Library/PostGreSQL/9.1/Bin > > My guess is that that path is not in you library-search path. Try 'ld > --verbose' on the commandline. See which search-directories are used, > and add a symlink in one of them. > > Or you can add the postgres3dyn unit to your uses-list, and call > 'InitialisePostgres3('Library/PostGreSQL/9.1/Bin/libpq.dylib');' before > you do anything db-related. > > -- > My Lazarus blog: http://www.lazarussupport.com/lazarus/weblog > > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus >

Reply by email

Joost van der Sluis
to Tom Russell: I tried adding the unti to my uses as well as the snippet you gave but it says its the…
Tom Russell wrote 5 lines
I tried adding the unti to my uses as well as the snippet you gave but it says its the wrong number of parameters? I dont see where that even accepts any really. Or Im confused?

Could be due to the different fpc-version. Ctrl-click on it to find out how it is defined.

Joost.

Reply by email

Tom Russell
to Joost van der Sluis

Its like this:

Procedure InitialisePostgres3;
begin
  inc(RefCount);
  if RefCount = 1 then
    begin
    Postgres3LibraryHandle := loadlibrary(pqlib);
    if Postgres3LibraryHandle = nilhandle then
      begin
      RefCount := 0;
      Raise EInOutError.Create('Can not load PosgreSQL client. Is it
installed? ('+pqlib+')');
      end;
    pointer(PQconnectStart) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQconnectStart');
    pointer(PQconnectPoll) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQconnectPoll');
    pointer(PQconnectdb) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQconnectdb');
    pointer(PQsetdbLogin) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQsetdbLogin');
    pointer(PQfinish) := GetProcedureAddress(Postgres3LibraryHandle,'PQfinish');
    pointer(PQconndefaults) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQconndefaults');
    pointer(PQconninfoFree) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQconninfoFree');
    pointer(PQresetStart) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQresetStart');
    pointer(PQresetPoll) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQresetPoll');
    pointer(PQreset) := GetProcedureAddress(Postgres3LibraryHandle,'PQreset');
    pointer(PQrequestCancel) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQrequestCancel');
    pointer(PQdb) := GetProcedureAddress(Postgres3LibraryHandle,'PQdb');
    pointer(PQuser) := GetProcedureAddress(Postgres3LibraryHandle,'PQuser');
    pointer(PQpass) := GetProcedureAddress(Postgres3LibraryHandle,'PQpass');
    pointer(PQhost) := GetProcedureAddress(Postgres3LibraryHandle,'PQhost');
    pointer(PQport) := GetProcedureAddress(Postgres3LibraryHandle,'PQport');
    pointer(PQtty) := GetProcedureAddress(Postgres3LibraryHandle,'PQtty');
    pointer(PQoptions) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQoptions');
    pointer(PQstatus) := GetProcedureAddress(Postgres3LibraryHandle,'PQstatus');
    pointer(PQtransactionStatus) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQtransactionStatus');
    pointer(PQparameterStatus) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQparameterStatus');
    pointer(PQprotocolVersion) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQprotocolVersion');
    pointer(PQerrorMessage) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQerrorMessage');
    pointer(PQsocket) := GetProcedureAddress(Postgres3LibraryHandle,'PQsocket');
    pointer(PQbackendPID) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQbackendPID');
    pointer(PQclientEncoding) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQclientEncoding');
    pointer(PQsetClientEncoding) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQsetClientEncoding');
{$ifdef USE_SSL}
    pointer(PQgetssl) := GetProcedureAddress(Postgres3LibraryHandle,'PQgetssl');
{$endif}
    pointer(PQsetErrorVerbosity) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQsetErrorVerbosity');
    pointer(PQtrace) := GetProcedureAddress(Postgres3LibraryHandle,'PQtrace');
    pointer(PQuntrace) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQuntrace');
    pointer(PQsetNoticeReceiver) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQsetNoticeReceiver');
    pointer(PQsetNoticeProcessor) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQsetNoticeProcessor');
    pointer(PQexec) := GetProcedureAddress(Postgres3LibraryHandle,'PQexec');
    pointer(PQexecParams) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQexecParams');
    pointer(PQexecPrepared) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQexecPrepared');
    pointer(PQPrepare) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQprepare');
    pointer(PQsendQuery) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQsendQuery');
    pointer(PQsendQueryParams) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQsendQueryParams');
    pointer(PQsendQueryPrepared) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQsendQueryPrepared');
    pointer(PQgetResult) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQgetResult');
    pointer(PQisBusy) := GetProcedureAddress(Postgres3LibraryHandle,'PQisBusy');
    pointer(PQconsumeInput) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQconsumeInput');
    pointer(PQnotifies) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQnotifies');
    pointer(PQputCopyData) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQputCopyData');
    pointer(PQputCopyEnd) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQputCopyEnd');
    pointer(PQgetCopyData) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQgetCopyData');
    pointer(PQgetline) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQgetline');
    pointer(PQputline) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQputline');
    pointer(PQgetlineAsync) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQgetlineAsync');
    pointer(PQputnbytes) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQputnbytes');
    pointer(PQendcopy) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQendcopy');
    pointer(PQsetnonblocking) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQsetnonblocking');
    pointer(PQisnonblocking) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQisnonblocking');
    pointer(PQflush) := GetProcedureAddress(Postgres3LibraryHandle,'PQflush');
    pointer(PQfn) := GetProcedureAddress(Postgres3LibraryHandle,'PQfn');
    pointer(PQresultStatus) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQresultStatus');
    pointer(PQresStatus) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQresStatus');
    pointer(PQresultErrorMessage) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQresultErrorMessage');
    pointer(PQresultErrorField) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQresultErrorField');
    pointer(PQntuples) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQntuples');
    pointer(PQnfields) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQnfields');
    pointer(PQbinaryTuples) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQbinaryTuples');
    pointer(PQfname) := GetProcedureAddress(Postgres3LibraryHandle,'PQfname');
    pointer(PQfnumber) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQfnumber');
    pointer(PQftable) := GetProcedureAddress(Postgres3LibraryHandle,'PQftable');
    pointer(PQftablecol) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQftablecol');
    pointer(PQfformat) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQfformat');
    pointer(PQftype) := GetProcedureAddress(Postgres3LibraryHandle,'PQftype');
    pointer(PQfsize) := GetProcedureAddress(Postgres3LibraryHandle,'PQfsize');
    pointer(PQfmod) := GetProcedureAddress(Postgres3LibraryHandle,'PQfmod');
    pointer(PQcmdStatus) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQcmdStatus');
    pointer(PQoidStatus) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQoidStatus');
    pointer(PQoidValue) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQoidValue');
    pointer(PQcmdTuples) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQcmdTuples');
    pointer(PQgetvalue) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQgetvalue');
    pointer(PQgetlength) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQgetlength');
    pointer(PQgetisnull) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQgetisnull');
    pointer(PQclear) := GetProcedureAddress(Postgres3LibraryHandle,'PQclear');
    pointer(PQfreemem) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQfreemem');
    pointer(PQmakeEmptyPGresult) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQmakeEmptyPGresult');
    pointer(PQescapeString) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQescapeString');
    pointer(PQescapeBytea) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQescapeBytea');
    pointer(PQunescapeBytea) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQunescapeBytea');
    pointer(PQprint) := GetProcedureAddress(Postgres3LibraryHandle,'PQprint');
    pointer(PQdisplayTuples) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQdisplayTuples');
    pointer(PQprintTuples) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQprintTuples');
    pointer(lo_open) := GetProcedureAddress(Postgres3LibraryHandle,'lo_open');
    pointer(lo_close) := GetProcedureAddress(Postgres3LibraryHandle,'lo_close');
    pointer(lo_read) := GetProcedureAddress(Postgres3LibraryHandle,'lo_read');
    pointer(lo_write) := GetProcedureAddress(Postgres3LibraryHandle,'lo_write');
    pointer(lo_lseek) := GetProcedureAddress(Postgres3LibraryHandle,'lo_lseek');
    pointer(lo_creat) := GetProcedureAddress(Postgres3LibraryHandle,'lo_creat');
    pointer(lo_tell) := GetProcedureAddress(Postgres3LibraryHandle,'lo_tell');
    pointer(lo_unlink) :=
GetProcedureAddress(Postgres3LibraryHandle,'lo_unlink');
    pointer(lo_import) :=
GetProcedureAddress(Postgres3LibraryHandle,'lo_import');
    pointer(lo_export) :=
GetProcedureAddress(Postgres3LibraryHandle,'lo_export');
    pointer(PQmblen) := GetProcedureAddress(Postgres3LibraryHandle,'PQmblen');
    pointer(PQenv2encoding) :=
GetProcedureAddress(Postgres3LibraryHandle,'PQenv2encoding');
    InitialiseDllist;
    end;
end;
Joost van der Sluis wrote 21 lines
On Mon, 2011-11-21 at 12:13 -0500, Tom Russell wrote: > I tried adding the unti to my uses as well as the snippet you gave but > it says its the wrong number of parameters? I dont see where that even > accepts any really. > > Or Im confused? Could be due to the different fpc-version. Ctrl-click on it to find out how it is defined. Joost. -- My Lazarus blog: http://www.lazarussupport.com/lazarus/weblog -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Tom Russell
to Tom Russell

I am not sure what the issue is and why it cannot load the dylib it needs. Apparently it must be exposed to other items as they work. I would not think its this difficult to use postgres with lazarus.

Tom Russell wrote 213 lines
Its like this: Procedure InitialisePostgres3; begin ?inc(RefCount); ?if RefCount = 1 then ? ?begin ? ?Postgres3LibraryHandle := loadlibrary(pqlib); ? ?if Postgres3LibraryHandle = nilhandle then ? ? ?begin ? ? ?RefCount := 0; ? ? ?Raise EInOutError.Create('Can not load PosgreSQL client. Is it installed? ('+pqlib+')'); ? ? ?end; ? ?pointer(PQconnectStart) := GetProcedureAddress(Postgres3LibraryHandle,'PQconnectStart'); ? ?pointer(PQconnectPoll) := GetProcedureAddress(Postgres3LibraryHandle,'PQconnectPoll'); ? ?pointer(PQconnectdb) := GetProcedureAddress(Postgres3LibraryHandle,'PQconnectdb'); ? ?pointer(PQsetdbLogin) := GetProcedureAddress(Postgres3LibraryHandle,'PQsetdbLogin'); ? ?pointer(PQfinish) := GetProcedureAddress(Postgres3LibraryHandle,'PQfinish'); ? ?pointer(PQconndefaults) := GetProcedureAddress(Postgres3LibraryHandle,'PQconndefaults'); ? ?pointer(PQconninfoFree) := GetProcedureAddress(Postgres3LibraryHandle,'PQconninfoFree'); ? ?pointer(PQresetStart) := GetProcedureAddress(Postgres3LibraryHandle,'PQresetStart'); ? ?pointer(PQresetPoll) := GetProcedureAddress(Postgres3LibraryHandle,'PQresetPoll'); ? ?pointer(PQreset) := GetProcedureAddress(Postgres3LibraryHandle,'PQreset'); ? ?pointer(PQrequestCancel) := GetProcedureAddress(Postgres3LibraryHandle,'PQrequestCancel'); ? ?pointer(PQdb) := GetProcedureAddress(Postgres3LibraryHandle,'PQdb'); ? ?pointer(PQuser) := GetProcedureAddress(Postgres3LibraryHandle,'PQuser'); ? ?pointer(PQpass) := GetProcedureAddress(Postgres3LibraryHandle,'PQpass'); ? ?pointer(PQhost) := GetProcedureAddress(Postgres3LibraryHandle,'PQhost'); ? ?pointer(PQport) := GetProcedureAddress(Postgres3LibraryHandle,'PQport'); ? ?pointer(PQtty) := GetProcedureAddress(Postgres3LibraryHandle,'PQtty'); ? ?pointer(PQoptions) := GetProcedureAddress(Postgres3LibraryHandle,'PQoptions'); ? ?pointer(PQstatus) := GetProcedureAddress(Postgres3LibraryHandle,'PQstatus'); ? ?pointer(PQtransactionStatus) := GetProcedureAddress(Postgres3LibraryHandle,'PQtransactionStatus'); ? ?pointer(PQparameterStatus) := GetProcedureAddress(Postgres3LibraryHandle,'PQparameterStatus'); ? ?pointer(PQprotocolVersion) := GetProcedureAddress(Postgres3LibraryHandle,'PQprotocolVersion'); ? ?pointer(PQerrorMessage) := GetProcedureAddress(Postgres3LibraryHandle,'PQerrorMessage'); ? ?pointer(PQsocket) := GetProcedureAddress(Postgres3LibraryHandle,'PQsocket'); ? ?pointer(PQbackendPID) := GetProcedureAddress(Postgres3LibraryHandle,'PQbackendPID'); ? ?pointer(PQclientEncoding) := GetProcedureAddress(Postgres3LibraryHandle,'PQclientEncoding'); ? ?pointer(PQsetClientEncoding) := GetProcedureAddress(Postgres3LibraryHandle,'PQsetClientEncoding'); {$ifdef USE_SSL} ? ?pointer(PQgetssl) := GetProcedureAddress(Postgres3LibraryHandle,'PQgetssl'); {$endif} ? ?pointer(PQsetErrorVerbosity) := GetProcedureAddress(Postgres3LibraryHandle,'PQsetErrorVerbosity'); ? ?pointer(PQtrace) := GetProcedureAddress(Postgres3LibraryHandle,'PQtrace'); ? ?pointer(PQuntrace) := GetProcedureAddress(Postgres3LibraryHandle,'PQuntrace'); ? ?pointer(PQsetNoticeReceiver) := GetProcedureAddress(Postgres3LibraryHandle,'PQsetNoticeReceiver'); ? ?pointer(PQsetNoticeProcessor) := GetProcedureAddress(Postgres3LibraryHandle,'PQsetNoticeProcessor'); ? ?pointer(PQexec) := GetProcedureAddress(Postgres3LibraryHandle,'PQexec'); ? ?pointer(PQexecParams) := GetProcedureAddress(Postgres3LibraryHandle,'PQexecParams'); ? ?pointer(PQexecPrepared) := GetProcedureAddress(Postgres3LibraryHandle,'PQexecPrepared'); ? ?pointer(PQPrepare) := GetProcedureAddress(Postgres3LibraryHandle,'PQprepare'); ? ?pointer(PQsendQuery) := GetProcedureAddress(Postgres3LibraryHandle,'PQsendQuery'); ? ?pointer(PQsendQueryParams) := GetProcedureAddress(Postgres3LibraryHandle,'PQsendQueryParams'); ? ?pointer(PQsendQueryPrepared) := GetProcedureAddress(Postgres3LibraryHandle,'PQsendQueryPrepared'); ? ?pointer(PQgetResult) := GetProcedureAddress(Postgres3LibraryHandle,'PQgetResult'); ? ?pointer(PQisBusy) := GetProcedureAddress(Postgres3LibraryHandle,'PQisBusy'); ? ?pointer(PQconsumeInput) := GetProcedureAddress(Postgres3LibraryHandle,'PQconsumeInput'); ? ?pointer(PQnotifies) := GetProcedureAddress(Postgres3LibraryHandle,'PQnotifies'); ? ?pointer(PQputCopyData) := GetProcedureAddress(Postgres3LibraryHandle,'PQputCopyData'); ? ?pointer(PQputCopyEnd) := GetProcedureAddress(Postgres3LibraryHandle,'PQputCopyEnd'); ? ?pointer(PQgetCopyData) := GetProcedureAddress(Postgres3LibraryHandle,'PQgetCopyData'); ? ?pointer(PQgetline) := GetProcedureAddress(Postgres3LibraryHandle,'PQgetline'); ? ?pointer(PQputline) := GetProcedureAddress(Postgres3LibraryHandle,'PQputline'); ? ?pointer(PQgetlineAsync) := GetProcedureAddress(Postgres3LibraryHandle,'PQgetlineAsync'); ? ?pointer(PQputnbytes) := GetProcedureAddress(Postgres3LibraryHandle,'PQputnbytes'); ? ?pointer(PQendcopy) := GetProcedureAddress(Postgres3LibraryHandle,'PQendcopy'); ? ?pointer(PQsetnonblocking) := GetProcedureAddress(Postgres3LibraryHandle,'PQsetnonblocking'); ? ?pointer(PQisnonblocking) := GetProcedureAddress(Postgres3LibraryHandle,'PQisnonblocking'); ? ?pointer(PQflush) := GetProcedureAddress(Postgres3LibraryHandle,'PQflush'); ? ?pointer(PQfn) := GetProcedureAddress(Postgres3LibraryHandle,'PQfn'); ? ?pointer(PQresultStatus) := GetProcedureAddress(Postgres3LibraryHandle,'PQresultStatus'); ? ?pointer(PQresStatus) := GetProcedureAddress(Postgres3LibraryHandle,'PQresStatus'); ? ?pointer(PQresultErrorMessage) := GetProcedureAddress(Postgres3LibraryHandle,'PQresultErrorMessage'); ? ?pointer(PQresultErrorField) := GetProcedureAddress(Postgres3LibraryHandle,'PQresultErrorField'); ? ?pointer(PQntuples) := GetProcedureAddress(Postgres3LibraryHandle,'PQntuples'); ? ?pointer(PQnfields) := GetProcedureAddress(Postgres3LibraryHandle,'PQnfields'); ? ?pointer(PQbinaryTuples) := GetProcedureAddress(Postgres3LibraryHandle,'PQbinaryTuples'); ? ?pointer(PQfname) := GetProcedureAddress(Postgres3LibraryHandle,'PQfname'); ? ?pointer(PQfnumber) := GetProcedureAddress(Postgres3LibraryHandle,'PQfnumber'); ? ?pointer(PQftable) := GetProcedureAddress(Postgres3LibraryHandle,'PQftable'); ? ?pointer(PQftablecol) := GetProcedureAddress(Postgres3LibraryHandle,'PQftablecol'); ? ?pointer(PQfformat) := GetProcedureAddress(Postgres3LibraryHandle,'PQfformat'); ? ?pointer(PQftype) := GetProcedureAddress(Postgres3LibraryHandle,'PQftype'); ? ?pointer(PQfsize) := GetProcedureAddress(Postgres3LibraryHandle,'PQfsize'); ? ?pointer(PQfmod) := GetProcedureAddress(Postgres3LibraryHandle,'PQfmod'); ? ?pointer(PQcmdStatus) := GetProcedureAddress(Postgres3LibraryHandle,'PQcmdStatus'); ? ?pointer(PQoidStatus) := GetProcedureAddress(Postgres3LibraryHandle,'PQoidStatus'); ? ?pointer(PQoidValue) := GetProcedureAddress(Postgres3LibraryHandle,'PQoidValue'); ? ?pointer(PQcmdTuples) := GetProcedureAddress(Postgres3LibraryHandle,'PQcmdTuples'); ? ?pointer(PQgetvalue) := GetProcedureAddress(Postgres3LibraryHandle,'PQgetvalue'); ? ?pointer(PQgetlength) := GetProcedureAddress(Postgres3LibraryHandle,'PQgetlength'); ? ?pointer(PQgetisnull) := GetProcedureAddress(Postgres3LibraryHandle,'PQgetisnull'); ? ?pointer(PQclear) := GetProcedureAddress(Postgres3LibraryHandle,'PQclear'); ? ?pointer(PQfreemem) := GetProcedureAddress(Postgres3LibraryHandle,'PQfreemem'); ? ?pointer(PQmakeEmptyPGresult) := GetProcedureAddress(Postgres3LibraryHandle,'PQmakeEmptyPGresult'); ? ?pointer(PQescapeString) := GetProcedureAddress(Postgres3LibraryHandle,'PQescapeString'); ? ?pointer(PQescapeBytea) := GetProcedureAddress(Postgres3LibraryHandle,'PQescapeBytea'); ? ?pointer(PQunescapeBytea) := GetProcedureAddress(Postgres3LibraryHandle,'PQunescapeBytea'); ? ?pointer(PQprint) := GetProcedureAddress(Postgres3LibraryHandle,'PQprint'); ? ?pointer(PQdisplayTuples) := GetProcedureAddress(Postgres3LibraryHandle,'PQdisplayTuples'); ? ?pointer(PQprintTuples) := GetProcedureAddress(Postgres3LibraryHandle,'PQprintTuples'); ? ?pointer(lo_open) := GetProcedureAddress(Postgres3LibraryHandle,'lo_open'); ? ?pointer(lo_close) := GetProcedureAddress(Postgres3LibraryHandle,'lo_close'); ? ?pointer(lo_read) := GetProcedureAddress(Postgres3LibraryHandle,'lo_read'); ? ?pointer(lo_write) := GetProcedureAddress(Postgres3LibraryHandle,'lo_write'); ? ?pointer(lo_lseek) := GetProcedureAddress(Postgres3LibraryHandle,'lo_lseek'); ? ?pointer(lo_creat) := GetProcedureAddress(Postgres3LibraryHandle,'lo_creat'); ? ?pointer(lo_tell) := GetProcedureAddress(Postgres3LibraryHandle,'lo_tell'); ? ?pointer(lo_unlink) := GetProcedureAddress(Postgres3LibraryHandle,'lo_unlink'); ? ?pointer(lo_import) := GetProcedureAddress(Postgres3LibraryHandle,'lo_import'); ? ?pointer(lo_export) := GetProcedureAddress(Postgres3LibraryHandle,'lo_export'); ? ?pointer(PQmblen) := GetProcedureAddress(Postgres3LibraryHandle,'PQmblen'); ? ?pointer(PQenv2encoding) := GetProcedureAddress(Postgres3LibraryHandle,'PQenv2encoding'); ? ?InitialiseDllist; ? ?end; end; On Mon, Nov 21, 2011 at 12:28 PM, Joost van der Sluis wrote: > On Mon, 2011-11-21 at 12:13 -0500, Tom Russell wrote: >> I tried adding the unti to my uses as well as the snippet you gave but >> it says its the wrong number of parameters? I dont see where that even >> accepts any really. >> >> Or Im confused? > > Could be due to the different fpc-version. Ctrl-click on it to find out > how it is defined. > > Joost. > -- > My Lazarus blog: http://www.lazarussupport.com/lazarus/weblog > > > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus >

Reply by email

Tom Russell
to Tom Russell

I tried placing my dylib file in the directory from which my app is and it still does not find the file. There must be something simple i am missing as I cannot figure out where the PQConnection is looking for this file either.

Tom Russell wrote 219 lines
I am not sure what the issue is and why it cannot load the dylib it needs. Apparently it must be exposed to other items as they work. I would not think its this difficult to use postgres with lazarus. On Mon, Nov 21, 2011 at 3:36 PM, Tom Russell wrote: > Its like this: > > Procedure InitialisePostgres3; > > begin > ?inc(RefCount); > ?if RefCount = 1 then > ? ?begin > ? ?Postgres3LibraryHandle := loadlibrary(pqlib); > ? ?if Postgres3LibraryHandle = nilhandle then > ? ? ?begin > ? ? ?RefCount := 0; > ? ? ?Raise EInOutError.Create('Can not load PosgreSQL client. Is it > installed? ('+pqlib+')'); > ? ? ?end; > > ? ?pointer(PQconnectStart) := > GetProcedureAddress(Postgres3LibraryHandle,'PQconnectStart'); > ? ?pointer(PQconnectPoll) := > GetProcedureAddress(Postgres3LibraryHandle,'PQconnectPoll'); > ? ?pointer(PQconnectdb) := > GetProcedureAddress(Postgres3LibraryHandle,'PQconnectdb'); > ? ?pointer(PQsetdbLogin) := > GetProcedureAddress(Postgres3LibraryHandle,'PQsetdbLogin'); > ? ?pointer(PQfinish) := GetProcedureAddress(Postgres3LibraryHandle,'PQfinish'); > ? ?pointer(PQconndefaults) := > GetProcedureAddress(Postgres3LibraryHandle,'PQconndefaults'); > ? ?pointer(PQconninfoFree) := > GetProcedureAddress(Postgres3LibraryHandle,'PQconninfoFree'); > ? ?pointer(PQresetStart) := > GetProcedureAddress(Postgres3LibraryHandle,'PQresetStart'); > ? ?pointer(PQresetPoll) := > GetProcedureAddress(Postgres3LibraryHandle,'PQresetPoll'); > ? ?pointer(PQreset) := GetProcedureAddress(Postgres3LibraryHandle,'PQreset'); > ? ?pointer(PQrequestCancel) := > GetProcedureAddress(Postgres3LibraryHandle,'PQrequestCancel'); > ? ?pointer(PQdb) := GetProcedureAddress(Postgres3LibraryHandle,'PQdb'); > ? ?pointer(PQuser) := GetProcedureAddress(Postgres3LibraryHandle,'PQuser'); > ? ?pointer(PQpass) := GetProcedureAddress(Postgres3LibraryHandle,'PQpass'); > ? ?pointer(PQhost) := GetProcedureAddress(Postgres3LibraryHandle,'PQhost'); > ? ?pointer(PQport) := GetProcedureAddress(Postgres3LibraryHandle,'PQport'); > ? ?pointer(PQtty) := GetProcedureAddress(Postgres3LibraryHandle,'PQtty'); > ? ?pointer(PQoptions) := > GetProcedureAddress(Postgres3LibraryHandle,'PQoptions'); > ? ?pointer(PQstatus) := GetProcedureAddress(Postgres3LibraryHandle,'PQstatus'); > ? ?pointer(PQtransactionStatus) := > GetProcedureAddress(Postgres3LibraryHandle,'PQtransactionStatus'); > ? ?pointer(PQparameterStatus) := > GetProcedureAddress(Postgres3LibraryHandle,'PQparameterStatus'); > ? ?pointer(PQprotocolVersion) := > GetProcedureAddress(Postgres3LibraryHandle,'PQprotocolVersion'); > ? ?pointer(PQerrorMessage) := > GetProcedureAddress(Postgres3LibraryHandle,'PQerrorMessage'); > ? ?pointer(PQsocket) := GetProcedureAddress(Postgres3LibraryHandle,'PQsocket'); > ? ?pointer(PQbackendPID) := > GetProcedureAddress(Postgres3LibraryHandle,'PQbackendPID'); > ? ?pointer(PQclientEncoding) := > GetProcedureAddress(Postgres3LibraryHandle,'PQclientEncoding'); > ? ?pointer(PQsetClientEncoding) := > GetProcedureAddress(Postgres3LibraryHandle,'PQsetClientEncoding'); > {$ifdef USE_SSL} > ? ?pointer(PQgetssl) := GetProcedureAddress(Postgres3LibraryHandle,'PQgetssl'); > {$endif} > ? ?pointer(PQsetErrorVerbosity) := > GetProcedureAddress(Postgres3LibraryHandle,'PQsetErrorVerbosity'); > ? ?pointer(PQtrace) := GetProcedureAddress(Postgres3LibraryHandle,'PQtrace'); > ? ?pointer(PQuntrace) := > GetProcedureAddress(Postgres3LibraryHandle,'PQuntrace'); > ? ?pointer(PQsetNoticeReceiver) := > GetProcedureAddress(Postgres3LibraryHandle,'PQsetNoticeReceiver'); > ? ?pointer(PQsetNoticeProcessor) := > GetProcedureAddress(Postgres3LibraryHandle,'PQsetNoticeProcessor'); > ? ?pointer(PQexec) := GetProcedureAddress(Postgres3LibraryHandle,'PQexec'); > ? ?pointer(PQexecParams) := > GetProcedureAddress(Postgres3LibraryHandle,'PQexecParams'); > ? ?pointer(PQexecPrepared) := > GetProcedureAddress(Postgres3LibraryHandle,'PQexecPrepared'); > ? ?pointer(PQPrepare) := > GetProcedureAddress(Postgres3LibraryHandle,'PQprepare'); > ? ?pointer(PQsendQuery) := > GetProcedureAddress(Postgres3LibraryHandle,'PQsendQuery'); > ? ?pointer(PQsendQueryParams) := > GetProcedureAddress(Postgres3LibraryHandle,'PQsendQueryParams'); > ? ?pointer(PQsendQueryPrepared) := > GetProcedureAddress(Postgres3LibraryHandle,'PQsendQueryPrepared'); > ? ?pointer(PQgetResult) := > GetProcedureAddress(Postgres3LibraryHandle,'PQgetResult'); > ? ?pointer(PQisBusy) := GetProcedureAddress(Postgres3LibraryHandle,'PQisBusy'); > ? ?pointer(PQconsumeInput) := > GetProcedureAddress(Postgres3LibraryHandle,'PQconsumeInput'); > ? ?pointer(PQnotifies) := > GetProcedureAddress(Postgres3LibraryHandle,'PQnotifies'); > ? ?pointer(PQputCopyData) := > GetProcedureAddress(Postgres3LibraryHandle,'PQputCopyData'); > ? ?pointer(PQputCopyEnd) := > GetProcedureAddress(Postgres3LibraryHandle,'PQputCopyEnd'); > ? ?pointer(PQgetCopyData) := > GetProcedureAddress(Postgres3LibraryHandle,'PQgetCopyData'); > ? ?pointer(PQgetline) := > GetProcedureAddress(Postgres3LibraryHandle,'PQgetline'); > ? ?pointer(PQputline) := > GetProcedureAddress(Postgres3LibraryHandle,'PQputline'); > ? ?pointer(PQgetlineAsync) := > GetProcedureAddress(Postgres3LibraryHandle,'PQgetlineAsync'); > ? ?pointer(PQputnbytes) := > GetProcedureAddress(Postgres3LibraryHandle,'PQputnbytes'); > ? ?pointer(PQendcopy) := > GetProcedureAddress(Postgres3LibraryHandle,'PQendcopy'); > ? ?pointer(PQsetnonblocking) := > GetProcedureAddress(Postgres3LibraryHandle,'PQsetnonblocking'); > ? ?pointer(PQisnonblocking) := > GetProcedureAddress(Postgres3LibraryHandle,'PQisnonblocking'); > ? ?pointer(PQflush) := GetProcedureAddress(Postgres3LibraryHandle,'PQflush'); > ? ?pointer(PQfn) := GetProcedureAddress(Postgres3LibraryHandle,'PQfn'); > ? ?pointer(PQresultStatus) := > GetProcedureAddress(Postgres3LibraryHandle,'PQresultStatus'); > ? ?pointer(PQresStatus) := > GetProcedureAddress(Postgres3LibraryHandle,'PQresStatus'); > ? ?pointer(PQresultErrorMessage) := > GetProcedureAddress(Postgres3LibraryHandle,'PQresultErrorMessage'); > ? ?pointer(PQresultErrorField) := > GetProcedureAddress(Postgres3LibraryHandle,'PQresultErrorField'); > ? ?pointer(PQntuples) := > GetProcedureAddress(Postgres3LibraryHandle,'PQntuples'); > ? ?pointer(PQnfields) := > GetProcedureAddress(Postgres3LibraryHandle,'PQnfields'); > ? ?pointer(PQbinaryTuples) := > GetProcedureAddress(Postgres3LibraryHandle,'PQbinaryTuples'); > ? ?pointer(PQfname) := GetProcedureAddress(Postgres3LibraryHandle,'PQfname'); > ? ?pointer(PQfnumber) := > GetProcedureAddress(Postgres3LibraryHandle,'PQfnumber'); > ? ?pointer(PQftable) := GetProcedureAddress(Postgres3LibraryHandle,'PQftable'); > ? ?pointer(PQftablecol) := > GetProcedureAddress(Postgres3LibraryHandle,'PQftablecol'); > ? ?pointer(PQfformat) := > GetProcedureAddress(Postgres3LibraryHandle,'PQfformat'); > ? ?pointer(PQftype) := GetProcedureAddress(Postgres3LibraryHandle,'PQftype'); > ? ?pointer(PQfsize) := GetProcedureAddress(Postgres3LibraryHandle,'PQfsize'); > ? ?pointer(PQfmod) := GetProcedureAddress(Postgres3LibraryHandle,'PQfmod'); > ? ?pointer(PQcmdStatus) := > GetProcedureAddress(Postgres3LibraryHandle,'PQcmdStatus'); > ? ?pointer(PQoidStatus) := > GetProcedureAddress(Postgres3LibraryHandle,'PQoidStatus'); > ? ?pointer(PQoidValue) := > GetProcedureAddress(Postgres3LibraryHandle,'PQoidValue'); > ? ?pointer(PQcmdTuples) := > GetProcedureAddress(Postgres3LibraryHandle,'PQcmdTuples'); > ? ?pointer(PQgetvalue) := > GetProcedureAddress(Postgres3LibraryHandle,'PQgetvalue'); > ? ?pointer(PQgetlength) := > GetProcedureAddress(Postgres3LibraryHandle,'PQgetlength'); > ? ?pointer(PQgetisnull) := > GetProcedureAddress(Postgres3LibraryHandle,'PQgetisnull'); > ? ?pointer(PQclear) := GetProcedureAddress(Postgres3LibraryHandle,'PQclear'); > ? ?pointer(PQfreemem) := > GetProcedureAddress(Postgres3LibraryHandle,'PQfreemem'); > ? ?pointer(PQmakeEmptyPGresult) := > GetProcedureAddress(Postgres3LibraryHandle,'PQmakeEmptyPGresult'); > ? ?pointer(PQescapeString) := > GetProcedureAddress(Postgres3LibraryHandle,'PQescapeString'); > ? ?pointer(PQescapeBytea) := > GetProcedureAddress(Postgres3LibraryHandle,'PQescapeBytea'); > ? ?pointer(PQunescapeBytea) := > GetProcedureAddress(Postgres3LibraryHandle,'PQunescapeBytea'); > ? ?pointer(PQprint) := GetProcedureAddress(Postgres3LibraryHandle,'PQprint'); > ? ?pointer(PQdisplayTuples) := > GetProcedureAddress(Postgres3LibraryHandle,'PQdisplayTuples'); > ? ?pointer(PQprintTuples) := > GetProcedureAddress(Postgres3LibraryHandle,'PQprintTuples'); > ? ?pointer(lo_open) := GetProcedureAddress(Postgres3LibraryHandle,'lo_open'); > ? ?pointer(lo_close) := GetProcedureAddress(Postgres3LibraryHandle,'lo_close'); > ? ?pointer(lo_read) := GetProcedureAddress(Postgres3LibraryHandle,'lo_read'); > ? ?pointer(lo_write) := GetProcedureAddress(Postgres3LibraryHandle,'lo_write'); > ? ?pointer(lo_lseek) := GetProcedureAddress(Postgres3LibraryHandle,'lo_lseek'); > ? ?pointer(lo_creat) := GetProcedureAddress(Postgres3LibraryHandle,'lo_creat'); > ? ?pointer(lo_tell) := GetProcedureAddress(Postgres3LibraryHandle,'lo_tell'); > ? ?pointer(lo_unlink) := > GetProcedureAddress(Postgres3LibraryHandle,'lo_unlink'); > ? ?pointer(lo_import) := > GetProcedureAddress(Postgres3LibraryHandle,'lo_import'); > ? ?pointer(lo_export) := > GetProcedureAddress(Postgres3LibraryHandle,'lo_export'); > ? ?pointer(PQmblen) := GetProcedureAddress(Postgres3LibraryHandle,'PQmblen'); > ? ?pointer(PQenv2encoding) := > GetProcedureAddress(Postgres3LibraryHandle,'PQenv2encoding'); > > ? ?InitialiseDllist; > ? ?end; > end; > > On Mon, Nov 21, 2011 at 12:28 PM, Joost van der Sluis wrote: >> On Mon, 2011-11-21 at 12:13 -0500, Tom Russell wrote: >>> I tried adding the unti to my uses as well as the snippet you gave but >>> it says its the wrong number of parameters? I dont see where that even >>> accepts any really. >>> >>> Or Im confused? >> >> Could be due to the different fpc-version. Ctrl-click on it to find out >> how it is defined. >> >> Joost. >> -- >> My Lazarus blog: http://www.lazarussupport.com/lazarus/weblog >> >> >> -- >> _______________________________________________ >> Lazarus mailing list >> >> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus >> >

Reply by email

Mark Morgan Lloyd
to Tom Russell
Tom Russell wrote
I tried placing my dylib file in the directory from which my app is and it still does not find the file. There must be something simple i am missing as I cannot figure out where the PQConnection is looking for this file either.

Noted that you're using OSX of which I have no experience, but on Linux using FPC 2.4.4 I had to set up a symlink for the library (see Joost's comments).

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Tom Russell
to Mark Morgan Lloyd

Yea I read that but the funny part is that my environment path has all the links for postgres so Im not sure where its looking for the dylib files. I read the readme for the postgres stuff in fpcsrc and it says in there you have to specify your path to those and then do a make and make install. Not sure if this is correct or not but I am also not sure how to do that either.

Does anyone know anything about that?

Thanks,
Tom

Mark Morgan Lloyd wrote 23 lines
Tom Russell wrote: > > I tried placing my dylib file in the directory from which my app is > and it still does not find the file. There must be something simple i > am missing as I cannot figure out where the PQConnection is looking > for this file either. Noted that you're using OSX of which I have no experience, but on Linux using FPC 2.4.4 I had to set up a symlink for the library (see Joost's comments). -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email