Page 1 of 3
how postgreSQL connect
Posted: Tue Jan 13, 2015 11:59 am
by dragancesu
I see threads on the forum but have not found an answer
I decided to PostgreSQL and now I'm looking for a way to access the HMG
There are examples of harbour and it works, but for example HMG does not work
if someone started c:\hmg.3.3.1\ samples\sql\ postgresql.1\demo.prg?
Re: how postgreSQL connect
Posted: Tue Jan 13, 2015 2:52 pm
by Rathinagiri
If it works in Harbour, it will work in HMG also.
Have you used HMGSQL library?
Re: how postgreSQL connect
Posted: Wed Jan 14, 2015 6:36 am
by dragancesu
Not yet
I try example from c:\hmg.3.3.1\harbour\conrib\hbppgsql - it's work
An try example from c:\hmg.3.3.1\ samples\sql\ postgresql.1 - don't work
I'll try your suggestion and write impression
Re: how postgreSQL connect
Posted: Wed Jan 14, 2015 9:45 am
by dragancesu
HMGSQL is created, exsist \lib\libhmgpgsql.a
Demo program
Code: Select all
#include "hmg.ch"
Function Main
Local cServer := '127.0.0.1'
Local cDataBase := 'test'
Local cUser := 'scott'
Local cPassWord := 'tiger'
Local dbo := 0
dbo := Connect2DB( cServer, cUser, cPassWord, cDataBase, 5432 )
aTable := SQL(dbo, "SELECT * FROM product ;")
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 800 ;
HEIGHT 510 ;
TITLE 'Hello World!' ;
MAIN
@ 10,10 GRID Grid_1 ;
WIDTH 770 ;
HEIGHT 440 ;
HEADERS { 'Product' , 'Name' , 'Price' } ;
WIDTHS { 100 , 120 , 120 } ;
VALUE { 1 , 1 } ;
ROWSOURCE "aTable"
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return
and result of compilaction
Code: Select all
Harbour 3.2.0dev (r1312060701)
Copyright (c) 1999-2013, http://harbour-project.org/
d:/Temp/hbmk_y1fddw.dir/demo.o:demo.c:(.data+0x18): undefined reference to `HB_FUN_CONNECT2DB'
d:/Temp/hbmk_y1fddw.dir/demo.o:demo.c:(.data+0x28): undefined reference to `HB_FUN_SQL'
collect2: ld returned 1 exit status
hbmk2[demo]: Error: Running linker. 1
gcc.exe d:/Temp/hbmk_y1fddw.dir/demo.o d:/Temp/hbmk_y1fddw.dir/hbmk_fehnxf.o C:/HARBOUR/hmg/sql/_temp.o -Wl,--nxcompat -Wl,--dynamicbase -mwindows -Wl,--start-group -lhmg -lcrypt -ledit -leditex -lgraph -lini -lreport -lhfcl -lmsvfw32 -lvfw32 -lhbct -lhbwin -lhbmzip -lminizip -lhbmemio -lhbmisc -lhbmysql -lmysql -lhbtip -lhbsqlit3 -lsddodbc -lrddsql -lsddmy -lhbodbc -lodbc32 -lhbhpdf -lhbfimage -lhbpgsql -lhbnetio -lxhb -lpng -llibhpdf -lhbvpdf -lhbzebra -lhbextern -lhbdebug -lhbvmmt -lhbrtl -lhblang -lhbcpage -lgtcgi -lgtpca -lgtstd -lgtwin -lgtwvt -lgtgui -lhbrdd -lhbuddall -lhbusrrdd -lrddntx -lrddcdx -lrddnsx -lrddfpt -lhbrdd -lhbhsx -lhbsix -lhbmacro -lhbcplr -lhbpp -lhbcommon -lhbmainwin -lkernel32 -luser32 -lgdi32 -ladvapi32 -lws2_32 -lwinspool -lcomctl32 -lcomdlg32 -lshell32 -luuid -lole32 -loleaut32 -lmpr -lwinmm -lmapi32 -limm32 -lmsimg32 -lwininet -lhbpcre -lhbzlib -Wl,--end-group -ohmgpgsql.exe -LC:/hmg/harbour/lib/win/mingw -LC:/hmg/lib
hbmk2: Error: Referenced, missing, but unknown function(s): CONNECT2DB(), SQL()
I know that hmgpgsql library must be incude in project, but I don't know how.
I need help
how postgreSQL connect
Posted: Wed Jan 14, 2015 11:36 am
by Pablo César
dragancesu wrote:I know that hmgpgsql library must be incude in project, but I don't know how.
I need help
Hi Dragan,
I have not much experience with SQL yet. But have you put at initial of your source:
REQUEST PGRDD ?
See also this:
viewtopic.php?p=33355#p33355
dragancesu wrote:An try example from c:\hmg.3.3.1\ samples\sql\ postgresql.1 - don't work
Did you mean:
Example at
C:\hmg.3.3.1\SAMPLES\HFCL\SQL\POSTGRESQL_1
I hope be helped you.
Rgds
Re: how postgreSQL connect
Posted: Wed Jan 14, 2015 12:39 pm
by Rathinagiri
libhmgpgsql.a is not pointed by default. So, you have to specify while compiling. That is the problem.
You have to add 'libs=hmgpgsql' in your .hbc file before compiling.
Re: how postgreSQL connect
Posted: Wed Jan 14, 2015 2:01 pm
by dragancesu
If possible I would ask you to post a simple example
Re: how postgreSQL connect
Posted: Wed Jan 21, 2015 3:54 pm
by dragancesu
For now I gave up PostgreSQL and I'll try MySQL
I see that the support for MySQL well done and works without problems
Re: how postgreSQL connect
Posted: Wed Jan 21, 2015 4:58 pm
by Rathinagiri

Now you have joined my club.
Why don't you try MariaDB, a drop in replacement of MySQL and still developed by the original developers of MySQL after MySQL was taken over by Oracle?
http://mariadb.org
Re: how postgreSQL connect
Posted: Mon Aug 26, 2019 8:29 pm
by AUGE_OHR
hi,
i'm search for quickest Way to transfer DBF into PG-Table
i found some PostgreSQL Sample in HMG.
c:\hmg.3.4.4\HARBOUR\contrib\hbpgsql\tests\SIMPLE.PRG
c:\hmg.3.4.4\HARBOUR\contrib\hbpgsql\tests\DBF2PG.PRG
c:\hmg.3.4.4\SAMPLES\HFCL\SQL\POSTGRESQL_1\demo.prg
---
i got all Sample working but \POSTGRESQL_1 was tricky ...
i add
Code: Select all
libs=c:\hmg.3.4.4\HARBOUR\lib\win\mingw\liblibpq.a
and reduce it to
now i seems to have access to LIBPQ.DLL API Function
Question : can i use it withOUT PGRDD only API function
i just want to "upsize" DBF to PG-Table so i do not need "navigation" at this step but Speed.
using \DBF2PG.PRG, which seems to use RDD ( oTable:Append( oRecord ) ), i can transfer about 700 Rec/Sec
using \POSTGRESQL_1 Demo i need 29 Sec for 100.000 "INSERT INTO test (...)" so > 3000 /Sec
ok that Sample have only 5 FIELD and no DBF access but i guess it will be better than 700 Rec/Sec
---
i have read about SQLMIX and how Array is used.
To optimize these queries the SQL index expresion should be
"FIELD1,FIELD2,_RECNO", but not "FIELD1,FIELD2" as written in INDEX ON
command.
Question : as i know PostgreSQL can only use 1 x FIELD as Index
--
Sample \POSTGRESQL_1 include GRID ( c:\hmg.3.4.4\SOURCE\h_grid.prg ) which seem to be a WC_LISTVIEW ("SysListView32")
i have Problem with this line
Code: Select all
COLUMNCONTROLS { aCtrl_1 , aCtrl_2 } ;
both aCtrl_1 and aCtrl_2 are not declare and i do not know how to use it (does not compile without this line)
p.s. i do not want to "alloweditInplace" just show data
need some help please how to use GRID Syntax