PgDAC

Getting Started

This page contains a quick introduction to setting up and using the PostgreSQL Data Access Components library. It gives a walkthrough for each part of the PgDAC usage process and points out the most relevant related topics in the documentation.

What is PgDAC?

PostgreSQL Data Access Components (PgDAC) is a component library which provides direct connectivity to PostgreSQL for Delphi, C++Builder and Lazarus (FPC), and helps you develop fast PostgreSQL-based database applications with these environments.

Many PgDAC classes are based on VCL, LCL and FMX classes and interfaces. PgDAC is a replacement for the Borland Database Engine, it provides native database connectivity, and is specifically designed as an interface to the PostgreSQL database.

An introduction to PgDAC is provided in the Overview section.

A list of the PgDAC features you may find useful is listed in the Features section.

An overview of the PgDAC component classes is provided in the Components List section.

Installing PgDAC

To install PgDAC, complete the following steps.

  1. Choose and download the version of the PgDAC installation program that is compatible with your IDE. For instance, if you are installing PgDAC 1.00, you should use the following files:

    For BDS 2006 and Turbo - pgdac100d10*.exe
    For Delphi 7 - pgdac1100d7*.exe

    For more information, visit the PgDAC download page.

  2. Close all running Borland applications.
  3. Launch the PgDAC installation program you downloaded in the first step and follow the instructions to install PgDAC.

By default, the PgDAC installation program should install compiled PgDAC libraries automatically on all IDEs.

To check if PgDAC has been installed properly, launch your IDE and make sure that the PgDAC page has been added to the Component palette and that a PgDAC menu was added to the Menu bar.

If you have bought PgDAC Professional Edition with Source Code with Source Code, you will be able to download both the compiled version of PgDAC and the PgDAC source code. The installation process for the compiled version is standard, as described above.The PgDAC source code must be compiled and installed manually. Consult the supplied ReadmeSrc.html file for more details.

To find out what gets installed with PgDAC or to troubleshoot your PgDAC installation, visit the Installation topic.

Working with the PgDAC demo projects

The PgDAC installation package includes a number of demo projects that demonstrate PgDAC capabilities and use patterns. The PgDAC demo projects are automatically installed in the PgDAC installation folder.

To quickly get started working with PgDAC, launch and explore the introductory PgDAC demo project, PgDacDemo, from your IDE. This demo project is a collection of demos that show how PgDAC can be used. The project creates a form which contains an explorer panel for browsing the included demos and a view panel for launching and viewing the selected demo.

PgDACDemo Walkthrough

  1. Launch your IDE.
  2. Choose File | Open Project from the menu bar
  3. Find the PgDAC directory and open the PgDacDemo project. This project should be located in the Demos\PgDacDemo folder.

    For example, if you are using Borland Developer Studio 2006, the demo project may be found at  

    \Program Files\Devart\PgDac for Delphi 2006\Demos\Win32\PgDacDemo\PgDacDemo.bdsproj

  4. Select Run | Run or press F9 to compile and launch the demo project. PgDacDemo should start, and a full-screen PgDAC Demo window with a toolbar, an explorer panel, and a view panel will open. The explorer panel will contain the list of all demo sub-projects included in PgDACDemo, and the view panel will contain an overview of each included demo.

    At this point, you will be able to browse through the available demos, read their descriptions, view their source code, and see the functionality provided by each demo for interacting with PostgreSQL. However, you will not be able to actually retrieve data from PostgreSQL or execute commands until you connect to the database.

  5. Click on the "Connect" button on the PgDacDemo toolbar. A Connect dialog box will open. Enter the connection parameters you use to connect to your PostgreSQL server and click "Connect" in the dialog box.

    Now you have a fully functional interface to your PostgreSQL server. You will be able to go through the different demos, to browse tables, create and drop objects, and execute SQL commands.

    Warning! All changes you make to the database you are connected to, including creating and dropping objects used by the demo, will be permanent. Make sure you specify a test database in the connection step.

  6. Click on the "Create" button to create all objects that will be used by PgDacDemo. If some of these objects already exist in the database you have connected to, the following error message will appear.
  7. An error has occurred:
    #42S01Table 'dept' already exists
     
    You can manually create objects required for demo by using the following file: %PgDAC%\Demos\InstallDemoObjects.sql
    %PgDAC% is the PgDAC installation path on your computer.
    Ignore this exception?

    This is a standard warning from the object execution script. Click "Yes to All" to ignore this message. PgDacDemo will create the PgDacDemo objects on the server you have connected to.

  8. Choose a demo that demonstrates an aspect of working with PostgreSQL that you are interested in, and play with the demo frame in the view window on the right. For example, to find out more about how to work with PostgreSQL tables, select the Table demo from the "Working with Components" folder. A simple PostgreSQL table browser will open in the view panel which will let you open a table in your database by specifying its name and clicking on the Open button.
  9. Click on the "Demo source" button in the PgDacDemo toolbar to find out how the demo you selected was implemented. The source code behind the demo project will appear in the view panel. Try to find the places where PgDAC components are used to connect to the database.
  10. Click on the "Form as text" button in the PgDacDemo toolbar to view the code behind the interface to the demo. Try to find the places where PgDAC components are created on the demo form.
  11. Repeat these steps for other demos listed in the explorer window. The available demos are organized in three folders.
  12. Working with components

    A collection of projects that show how to work with basic PgDAC components.

    General demos

    A collection of projects that show off the PgDAC technology and demonstrate some ways of working with data.

    PostgreSQL-specific demos

    A collection of projects that demonstrate how to incorporate PostgreSQL features in database applications.

  13. When you are finished working with the project, click on the "Drop" button in the PgDacDemo toolbar to remove all schema objects added in Step 6.

Other PgDAC demo projects

PgDAC is accompanied by a number of other demo projects. A description of all PgDAC demos is located in the Demo Projects topic.

Compiling and deploying your PgDAC project

Compiling PgDAC-based projects

By default, to compile a project that uses PgDAC classes, your IDE compiler needs to have access to the PgDAC dcu (obj) files. If you are compiling with runtime packages, the compiler will also need to have access to the PgDAC bpl files. All the appropriate settings for both these scenarios should take place automatically during installation of PgDAC. You should only need to modify your environment manually if you are using one of the PgDAC editions that comes with source code - PgDAC Professional Edition with Source Code or PgDAC Developer Edition with Source Code.

You can check that your environment is properly configured by trying to compile one of the PgDAC demo projects. If you have no problems compiling and launching the PgDAC demos, your environment has been properly configured.

For more information about which library files and environment changes are needed for compiling PgDAC-based projects, consult the Installation topic.

Deploying PgDAC-based projects

To deploy an application that uses PgDAC, you will need to make sure the target workstation has access to the following files.

If you are evaluating deploying projects with PgDAC Trial Edition, you will also need to deploy some additional bpl files with your application even if you are compiling without runtime packages. As another trial limitation for C++Builder, applications written with PgDAC Trial Edition for C++Builder will only work if the C++Builder IDE is launched. More information about PgDAC Trial Edition limitations is provided here.

A list of the files which may need to be deployed with PgDAC-based applications is included in the Deployment topic.

Using the PgDAC documentation

The PgDAC documentation describes how to install and configure PgDAC, how to use PgDAC Demo Projects, and how to use the PgDAC libraries.

The PgDAC documentation includes a detailed reference of all PgDAC components and classes. Many of the PgDAC components and classes inherit or implement members from other VCL, LCL and FMX classes and interfaces. The product documentation also includes a summary of all members within each of these classes. To view a detailed description of a particular component, look it up in the Components List section. To find out more about a specific standard VCL/LCL class a PgDAC component is inherited from, see the corresponding topic in your IDE documentation.

At install time, the PgDAC documentation is integrated into your IDE. It can be invoked from the PgDAC menu added to the Menu Bar, or by pressing F1 in an object inspector or on a selected code segment.

How to get help with PgDAC

There are a number of resources for finding help on using PgDAC classes in your project.

For more information, consult the Getting Support topic.

© 1997-2024 Devart. All Rights Reserved. Request Support DAC Forum Provide Feedback