# PgAccess - a Tcl/Tk interface for PostgreSQL

- Introduction
  - What is PgAccess?
  - How to get help with PgAccess
- Getting Started
  - How to get PgAccess
  - How to uncompress PgAccess
  - Putting PgAccess where it will be found
  - Starting PgAccess
  - Installing PgAccess under IRIX 5.3
- Common Problems with PgAccess
  - Connection failure
  - libpgtcl not found
  - Locale specific characters
  - Problems with PostgreSQL 6.3.x

PgAccess - Introduction

# PgAccess - Introduction

## What is PgAccess?

PgAccess is a graphical user interface for the PostgreSQL database management system written in the Tcl/Tk scripting language by Constantin Teodorescu. It allows the user to interact with PostgreSQL in a manner similar to many PC database applications, with menu choices and graphical tools like buttons. This means that the user can avoid the basic command line interface for most common tasks. PgAccess doesn't change the way PostgreSQL operates, just makes it easier to use for those familiar with graphical interfaces.

Obviously, you must have PostgreSQL installed and running, and Tcl/Tk on your system before you can use PgAccess.

PgAccess is an "open source" application. The source code is available to the user, and may be modified by the user. The user can fix a bug, or change the way a function operates. You may not want to get that involved with the programming, but you have the option to do so. If you feel you have made an improvement to the program, you are encouraged to share it with other users.

If you are not familiar with how open source software can be altered and redistributed, please read this.

## How to get help with PgAccess

The mailing list for PgAccess is: pgsql-interfaces@postgresql.org

If you have any questions regarding PgAccess you should subscribe to this list in the following way:

First subscribe to the list by sending an email message to:

`pgsql-interfaces-request@postgresql.org`

Send a single line in the body of the message as follows:

`subscribe`

In a short time you should receive a message beginning like this:

`Welcome to the pgsql-interfaces mailing list!
...`

This will contain instructions on how to remove yourself from the mailing list, so save that message. You may only want to ask a few questions and then stop receiving messages.

You may also email Constantin Teodorescu directly, although writing to a mailing list with many correspondents will often produce a quicker answer.

Back to index

PgAccess on Irix

# INSTALLING PgAccess UNDER IRIX 5.3.

This HOWO-TO make PgAccess working under Irix is written by Stuart Rison

These are the steps that I had to follow to get pgaccess to run on an INDIGO2 running postgreSQL 6.3.2 under IRIX 5.3. I make no guarantee whatsoever that the same step will work for others but at least it should point you in the right direction. Also, I am a biologist by training so I only got pgaccess working by fudging (that is, trial and error) this means that some of the steps may be unnecessary (e.g. compiling $postgreSQL_source/src/interfaces/libpgtcl as both a shared and static library) and they certainly haven't been optimised (I know nothing about compiler switches etc.).

1) Requirements:

You will need:

- postgreSQL source (http://www.postgresql.org)
- tcl8.0 source (http://www.tclconsortium.org/)
- tk8.0 source (http://www.tclconsortium.org/)
- pgaccess source (http://www.flex.ro/pgaccess)

2) Installation:

a) tcl/tk:

You must first install tcl and then tk (in that order). I just used ./configure, no switches and gmake. Their installation should be trouble free. Then you must move headers and libraries to the right places so:

Header files: both tcl and tk have a header file (tcl.h and tk.h). The tcl.h file is in $tcl_source_dir/generic and the tk.h file is in $tk_source_dir/generic; both should be copied to /usr/local/include.

Libraries: compilation (with cc) of tcl and tk yield libraries libtcl8.0.a and libtk8.0.a in $source_dir/unix. Both should be copied to /usr/local/lib.

b) postgreSQL:

Make sure you have a fully patched postgreSQL source. If your ./configure says it can't load 'IRIX' settings then you most probably will need to patch ./configure.

Configure using ./configure with the following switches: ./configure --with-includes=/usr/local/include

--with-libraries=/usr/local/lib --with-tcl [this and previous line as one]

Then make, make install as usual

c) Compiling libpgtcl:

The source for libpgtcl is in $postgreSQL_directory/src/interfaces/libpgsql.

I do this twice. Once with just gmake. This produces a static library libpgtcl.a which I leave where it is (I don't know what to do with it but it may just come in handy). The I modify Makefile manually with a text editor. Essentially I modify two line:

before:

# Shared library stuff

install-shlib-dep := shlib :=

after:

# Shared library stuff

install-shlib-dep := install-shlib shlib := libpgtcl.so.1

Then gmake -f Makefile_modified. This creates two shared (.so) libraries: libpgtcl.so and libpgtcl.so.1. I can't tell the difference between them so I copied them both to /usr/lib/.

d) running pgaccess:

Uncompress pgaccess (usually with gunzip and tar). So long as 'wish' (a binary produced when compiling tk8.0) is somewhere in your path, you should be able to run pgaccess with:

wish -f $pgaccess_dir/pgaccess.tcl [postgreSQL_database_name]

e) et voila!

3) Concluding remarks:

As I stated at the start of this document, following the procedure indicated above worked for me. I am sure, however, that a few of the steps are unnecessary/non-optimised/stupid etc. If any Unix (IRIX) boffin is reading this and you spot anything you would like to comment/correct etc. please e-mail me (stuart@ludwig.ucl.ac.uk). Also, if you just have questions and think I might help, please contact me at the same e-mail.

Finally, I can accept no responsibility if these steps don't work for you or if it all goes horribly wrong and you 'damage' your computer trying them. Let common sense prevail!

Good luck

Stuart Rison LICR University College London London W1P 8BT
stuart@ludwig.ucl.ac.uk

Back to index
PgAccess - Common Problems

# Common Problems with PgAccess

## Connection failure

One of the most common initial problems is the message:

`Error connecting database
Connection to database failed
connectDB() failed: Is the
postmaster running and
accepting TCP/IP (with -i)
connections at 'localhost' on
port '5432'?`

This usually occurs because the "postmaster" (the postgreSQL backend) was not started with the `-i` option. Usually just adding `-i` to the command line that starts the postmaster and restarting will fix this.

## libpgtcl not found

PgAccess requires a library of functions named `libpgtcl`. This should be available with the postgreSQL distribution, and is usually placed in the correct location when installing postgreSQL. First check that there is a file named `libpgtcl.so` (perhaps with a number appended - or `libpgtcl.dll` on Windows systems) on your system. If not, you will have to download and perhaps compile this library.

`ftp://ftp.flex.ro/pub/pgaccess`

is one place that you can download precompiled libpgtcl libraries for PgAccess.

## Locale specific characters

This problem occurs with some special characters used in different countries because PgAccess did not use fonts with `-ISO8859-1' encoding.

One solution was proposed by H.P.Heidinger ( hph@hphbbs.ruhr.de) and is very simple.

If you look in the file pgaccess.tcl, you will find the fonts declared in this manner:

`$ grep -e '-font' -i pgaccess.tcl
-font -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-* \
...`

The font declarations should be altered to:

`-font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-iso8859-1
...`

That is, inserting an asterisk between the first pair of hyphens, and changing the final two asterisks to `iso8859` and `1` respectively.

You can alter the source code by running the following script :

`#!/bin/sh
cp pgaccess.tcl pgaccess.tcl-org
cat pgaccess.tcl |\
sed -e's/\-\*\-\*\ /\-iso8859\-1\ /g' |\
sed -e's/\-\*\-\*\}/\-iso8859\-1}/g' |\
sed -e's/\-\*\-\*\]/\-iso8859\-1]/g' |\
sed -e's/\-\*\-\*$/\-iso8859\-1/g' |\
sed -e's/\-Clean\-/\-Fixed\-/g' |\
sed -e's/clean/fixed/g' >pgaccess.iso
mv pgaccess.iso pgaccess.tcl
chmod +x pgaccess.tcl`

The final version of PgAccess (1.0) will let the user decide what fonts will be used through a "preferences" dialog window.

a name="pg63">

## Problem with PostgreSQL 6.3.x

PgAccess 0.93 and later may have problems working with PostgreSQL 6.3.x. Changes in libpgtcl have been made to remove these, but if you are using PostgreSQL 6.3.x, this patch will allow you to get around the problems.

In the procedure `wpg_exec` change the following line:

`set pgsql(errmsg) [pg_result $pgsql(res) -error]`

to this:

`set pgsql(errmsg) "NO ERROR INFORMATION SUPPLIED"`

and the program will work. The only disadvantage is that with some error conditions, you will not get the appropriate error message from libpgtcl.

Back to index

PgAccess - Getting Started

# PgAccess - Getting Started

## How to get PgAccess

If you have this HTML help system, you have probably already downloaded PgAccess. If not, or you wish to download the latest version, it is available from the URL:

`http://www.flex.ro`

The home page will contain instructions on which files to download for your operating system. Download the file to a directory where the program will eventually reside (see below).

## How to uncompress PgAccess

PgAccess, like most applications available for download, is usually downloaded in compressed format to save download time. You must uncompress these files in order to use the application.

### UNIX (Linux, BSD, IRIX, Solaris, etc.)

The files will be compressed using "gzip" and packaged using "tar", and have filenames like this:

`pgaccess-n.nn.tar.gz`

Note that "n.nn" will be the version number in an actual file.

First decide where you want to have the program. A typical location on UNIX systems is `/usr/local/src/<name>`, where <name> is the name of the program. To use this location, download or move the "tar.gz" file to the directory `/usr/local/src`. Change to that directory, and uncompress the file with the command:

`tar -zxvf pgaccess-n.nn.tar.gz`

You should see the files listed as they are uncompressed and placed in the new directory, and now have a directory named:

`/usr/local/src/pgaccess`

In that directory will be all of the files that were packaged in the downloaded file. When you have PgAccess working, you can delete the file with the ".tar" or ".tar.gz" extension.

### Windows

The files will be compressed so that "WinZip" will uncompress the package. Just open the file with "WinZip" and the program files will be extracted.

## Putting PgAccess where it will be found

### UNIX

In order to run PgAccess easily, the program file "pgaccess.tcl" should be in a location on the "PATH" of the system. You can find out what the PATH is by entering:

`echo $PATH
/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:./:/usr/local/pgsql/bin`

Usually the directory `/usr/local/bin` will be in your PATH, and that is a fairly common place to put programs like PgAccess. Other common directories in the PATH are `/usr/bin` and `/usr/sbin`. Simply move the file "pgaccess.tcl" to the directory where you want it.

### Windows

You will usually link PgAccess to an icon, so just specify the full path to the program when you create the icon.

## Starting PgAccess

The easiest way to start PgAccess is to simply invoke the program by name:

`pgaccess.tcl`

If the program has been placed in a directory listed in the PATH, the PgAccess window should appear.

### Starting from a menu

Most users will want to link the program to a menu or icon so that it can be started using the mouse or other pointing device. Here is a method that will work on most Linux X-Windows systems. Create a file named "pgaccess" in the directory `/etc/X11/wmconfig` with the following contents:

`pgaccess name "PgAccess"
pgaccess description "postgreSQL frontend"
pgaccess mini-icon "mini-pgaccess.xpm"
pgaccess group "Applications"
pgaccess exec "pgaccess.tcl &"`

This assumes that you have an "Applications" sub-menu. You may prefer "Programs" or some other place. Also, you will have to create the "mini-pgaccess.xpm" icon if you want it to appear. You can edit an existing icon from the `/usr/share/icons/mini` directory in XPaint and rename it. When you next start an X-Windows session, there should be a "PgAccess" item on the menu that you have chosen. Clicking on this item should start PgAccess.

Back to index