Native PostgreSQL client for windoze

PGAccess.dll gives you easy access to PostgreSQL databases. PGAccess uses libpq classes to access postgreSQL natively.
PGAccess exports the classes CPgSQLConnection, CPgDynaset and CPgQuickQuery. The last class CPgQuickQuery combines the two first
and gives a dynaset like access to your queries. The libpq.dll that PGAccess uses is slightly modified to support GetScale and
GetPrecision methods.
To make a connection to a postgreSQL server just create an object of CPgSQLConnection, and use the method Connect(). Once the connection is established
use CPgQuickQuery to handle your queries. CPgQuickQuery::Select(CString SQL) both executes your query and collects the result in a dynaset.
Then you can access your data using CPgQuickQuery::GetValueAsString(int FieldIdx, CString& ReturnVal) or corresponding methods for long and double.
To navigate through the rows use standard recordset cursor methods MoveFirst(), MoveNext(), MovePrev(), MoveLast().

Example:


#include "pgaccess/pgsqlconnection.h"
#include "pgaccess/pgquickquery.h"


PGAccessTest::ConnectAndSelect()
//==============================
{
  CPgSQLConnection Conn;
  CPgQuickQuery Query(&Conn);
  Conn.Connect("192.168.1.2","JLU","","testdb");
  Query.Select("SELECT NAME,FIRM,TELEPHONE FROM CLIENT");
  ShowData(&Query)
}


void PGAccessTest::ShowData(CPgQuickQuery* Query)
//===============================================
{
  int nField;
  CString FieldNames,Data, Row, Cell;
  for (nField=0; nField < Query->GetFieldCount(); nField++)
  {
    if (nField)
    FieldNames = FieldNames + " , ";
    FieldNames = FieldNames + Query->GetFieldName(nField);
  }
  FieldNames = "Fieldnames: " + Query->FieldNames + "\n\n";

  if (!Query->MoveToRow(StartRow))
    return;
  for (int nRow=0; nRow < Query->RowCount; nRow++)
  {
    Row.Format("Row %d: ",nRow);
    for (nField=0; nField < Query->GetFieldCount(); nField++)
    {
      Query->GetValueByString(nField,Cell);
      if (nField)
        Row = Row + " , ";
      Row = Row + Cell;
    }
    Data = Data + Row + "\n";
    if (!Query->MoveNext())
      break;
  }
}

Both PGAccess and libpq are included in the following download. The package contains debug and release versions of the dll's and lib-files.

New from version 1.3 to 1.4:
* Columnbinding
* Fixed problem with floating point

Download PGAccess v1.4.0 package:
pgaccess_v14.zip - PGAccess and libpq dll's, lib's and headerfiles


Applicating PGAccess:

PgSQLLoader.zip
Usage example: PgSQLLoader is a console program which uses the PgAccess classes to import data from a field delimited datafile. It works pretty much like Oracle's sqlloader. All you need to do is tell PgSQLLoader is how the delimiter looks and which table and fields to insert the data into. You do this by writing an authorization script and a control script:


test.aut:
[DATABASE]    testdb
[USER]        JLU
[PASSWORD]    secret
[HOST]        192.168.1.2
[CONTROLFILE] test.con

test.con
[DATAFILE]    Customer.asc
[DELIMITER]   "#"
[INTO TABLE]  Customer
[FIELDS]      (Name,Address,City,Phonenumber)
[BUFFERSIZE]  50000
[CHUNKSIZE]   60


If you are experiencing any problems with downloading the software please contact me: jakob@jsg.dk

Download MySQLbroker:
mysqlbroker.zip - Requieres MySQL installed on the system