Hi,
When you create a Postgresql object using TPWServer():New (), you are prompted to confirm that you are accessing the database. Is it possible to avoid automatically opening this query ?
FW 1806
Natter wrote:Hi,
When you create a Postgresql object using TPWServer():New (), you are prompted to confirm that you are accessing the database. Is it possible to avoid automatically opening this query ?
FW 1806
oServer := TPQServer():New( cHost, cDataBase, cUser, cPassword, , cSchema )
for me it work ... hmNatter wrote:I pass all the parameters in, but the confirmation window still opens.
#require "hbpgsql" // i guess FW use libpq.lib pgsql.lib
#include "postgres.ch" // some Constant
PROCEDURE Main()
LOCAL conn, res, aTemp, x, y, pFile
LOCAL cHost := "localhost"
LOCAL cPort := "5432"
LOCAL cDb := "MyCatalog"
LOCAL cUser := "MyUser"
LOCAL cPass := "MyPW"
#IFDEF __XPP__
#ELSE
REQUEST HB_GT_WIN_DEFAULT
CLS
#ENDIF
conn := PQsetdbLogin( cHost, cPort, NIL, NIL, cDb, cUser, cPass )
? PQdb( conn ), PQuser( conn ), PQpass( conn ), PQhost( conn ), PQport( conn ), PQtty( conn ), PQoptions( conn )
* conn := PQconnectdb( "dbname = " + cDb + " host = localhost user = " + cUser + " password = " + cPass + " port = 5432" )
conn := PQconnectdb( "host = "+ cHost +;
" port = " +cPort +;
" dbname = " + cDb +;
" user = " + cUser +;
" password = " + cPass )
? PQstatus( conn ), PQerrorMessage( conn )
IF PQstatus( conn ) != CONNECTION_OK
QUIT
ENDIF
? "Blocking: ", PQisnonblocking( conn ), PQsetnonblocking( conn, .T. ), PQisnonblocking( conn )
pFile := PQtracecreate( "trace.log" )
PQtrace( conn, pFile )
? "Verbose: ", PQsetErrorVerbosity( conn, 2 )
? ;
"Protocol: ", PQprotocolVersion( conn ), ;
" Server Version: ", PQserverVersion( conn ), ;
" Client Encoding: ", PQsetClientEncoding( conn, "ASCII" ), ;
"New encode: ", PQclientEncoding( conn )
? PQdb( conn ), PQuser( conn ), PQpass( conn ), PQhost( conn ), PQport( conn ), PQtty( conn ), PQoptions( conn )
res := PQexec( conn, "drop table products" )
? PQresultStatus( res ), PQresultErrorMessage( res )
res := NIL
res := PQexec( conn, "create table products ( product_no numeric(10), name varchar(20), price numeric(10,2) )" )
? PQresultStatus( res ), PQresultErrorMessage( res )
res := PQexecParams( conn, "insert into products(product_no, name, price) values ($1, $2, $3)", { "2", "bread", "10.95" } )
? "Oid Row: ", PQoidValue( res ), PQoidStatus( res )
IF PQresultStatus( res ) != PGRES_COMMAND_OK
? PQresultStatus( res ), PQresultErrorMessage( res )
ENDIF
res := PQexec( conn, 'select price, name, product_no as "produto" from products' )
IF PQresultStatus( res ) != PGRES_TUPLES_OK
? PQresultStatus( res ), PQresultErrorMessage( res )
ENDIF
? "Binary: ", PQbinaryTuples( res )
? "Rows: ", PQntuples( res ), "Cols: ", PQnfields( res )
? PQfname( res, 1 ), PQftable( res, 1 ), PQftype( res, 1 ), PQfnumber( res, "name" ), PQfmod( res, 1 ), PQfsize( res, 1 ), PQgetisnull( res, 1, 1 )
aTemp := PQmetadata( res )
FOR x := 1 TO Len( aTemp )
? "Linha 1: "
FOR y := 1 TO 6
?? aTemp[ x ][ y ], ", "
NEXT
NEXT
? PQfcount( res )
? PQlastrec( res )
? PQgetvalue( res, 1, 2 )
? "Large Objects, always should be in a transaction..."
PQexec( conn, "begin" )
? ( x := lo_import( conn, __FILE__ ) )
? lo_export( conn, x, hb_FNameExtSet( __FILE__, ".new" ) )
? lo_unlink( conn, x )
PQexec( conn, "commit" )
PQuntrace( conn )
WAIT
RETURN
#ifndef HBPOSTGRES_CH_
#define HBPOSTGRES_CH_
#define CONNECTION_OK 0
#define CONNECTION_BAD 1
#define CONNECTION_STARTED 2
#define CONNECTION_MADE 3
#define CONNECTION_AWAITING_RESPONSE 4
#define CONNECTION_AUTH_OK 5
#define CONNECTION_SETENV 6
#define CONNECTION_SSL_STARTUP 7
#define CONNECTION_NEEDED 8
#define PGRES_EMPTY_QUERY 0
#define PGRES_COMMAND_OK 1
#define PGRES_TUPLES_OK 2
#define PGRES_COPY_OUT 3
#define PGRES_COPY_IN 4
#define PGRES_BAD_RESPONSE 5
#define PGRES_NONFATAL_ERROR 6
#define PGRES_FATAL_ERROR 7
#define PQTRANS_IDLE 0
#define PQTRANS_ACTIVE 1
#define PQTRANS_INTRANS 2
#define PQTRANS_INERROR 3
#define PQTRANS_UNKNOWN 4
/* PQmetadata() positions for array returned */
#define HBPG_META_FIELDNAME 1
#define HBPG_META_FIELDTYPE 2
#define HBPG_META_FIELDLEN 3
#define HBPG_META_FIELDDEC 4
#define HBPG_META_TABLE 5
#define HBPG_META_TABLECOL 6
#define HBPG_META_LEN_ 6
#endif
are you asking for SourceNatter wrote:Can there be source code of TPQServer class ?
PostGreSQL wrapper for MiniGUI (libpq)
Contributed by Viktor Szakats
Arranged for MiniGUI by Mitja Podgornik
Script makelib.bat creates PostgreSQL wrapper lib for Harbour (../Harbour/lib/hbpgsql.lib) and transforms
original libpq.lib in this map (MSVC COFF type) to Borland OMF type (../Harbour/lib/libpq.lib)
All headers and libpq.lib are from PostgreSQL version 8.4
5.5.2011
Mitja Podgornik
Updated:
PostGreSQL wrapper from harbour-core (https://github.com/vszakats/harbour-core)
All headers and libpq.lib are from PostgreSQL version 9.5
Petr Chornyj <myorg63@mail.ru>
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 87 guests