Skip to content
Tcl client side interface to PostgreSQL (libpgtcl)
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.travis Add configure-osx file Feb 21, 2018
doc Regenerate documentation with Docker (#30) Mar 4, 2019
generic Allow SQL statement to start with -- in pg_exec (same logic as pg_sel… May 10, 2019
playpen Install helper package sc_postgres by default Aug 26, 2015
tclconfig Update build to Tcl Extension Architecture (TEA) 3.9 Aug 8, 2015
tests Update version # May 14, 2019
win Upgrade to TEA 3.1 compliance. Nov 20, 2004
.gitignore More tracking of incr/decr refcounts. Jul 27, 2018
.travis.yml Travis OSX vm already has postgresql installed. Feb 21, 2018
ChangeLog Prepare for 2.2.0 release. Jun 21, 2017
LICENSE Clean up slightly confusing license text. Jul 20, 2017 For 2.4.1 and later symlink to /usr/local/bin/libpgtcl.$ext for cpptc… Dec 12, 2017
README.FreeBSD prefer/choose clang Mar 15, 2018
README.Linux Add README.Linux and remove configure. Mar 30, 2018
README.async Cleaning up the TODO list, README and README.async to get ready for a… Jun 22, 2004
README.macosx Prepare for v2.4.1 Dec 12, 2017 add travis build status icon to readme Feb 28, 2019
TODO Added playpen area, added code for messing with datatype names and OIDs. Nov 22, 2004
aclocal.m4 Move the install_name_tool magic to Makefile. Dec 6, 2017 Update version # May 14, 2019
libpgtcl.def Initial revision Nov 4, 2002 version bump for sc_postgres Jul 31, 2017
postgres-helpers.tcl bump sc_postgres version number Jul 31, 2017
win32.mak Initial revision Nov 4, 2002

Build Status

Thank you for downloading Pgtcl, a package that adds PostgreSQL interface extensions to the Tcl programming language... an open source project that's been in existence for nearly twenty years.


Pgtcl is now Tcl Extension Architecture (TEA) compliant, shipping with a standard "configure" script. It no longer needs to reside in a specific place within the Postgres source tree in order to build.

For standard builds to put things in subdirectories of /usr/local, you can often simply execute configure with no arguments at all...


The configure script will attempt to find where the Postgres includes and libraries are using pg_config, a program built and installed as part of Postgres. Alternatively, you can specify a path to the Postgres include files using --with-postgres-include and to the Postgres libraries using --with-postgres-lib.

If you had PostgreSQL installed into /usr/postgres and a Tcl build in /usr/pptcl, you might use something like

./configure --prefix=/usr/pptcl

With this style of configure command, you'll need to make sure pg_config (and the correct pg_config if you have postgres installed in multiple places) is in the PATH.

Alternatively you can still explicitly specify where the Postgres includes and libraries are found:

./configure --prefix=/usr/pptcl --with-postgres-include=/usr/postgres/include --with-postgres-lib=/usr/postgres/lib

The other configure parameters that may need tweaking are where Tcl's includes and libraries (and are. Although normally they will be in /usr/local/include and /usr/local/lib, in some cases they may reside elsewhere. If Tcl is built and installed from the FreeBSD ports tree, for example, they'll be in versioned subdirectories...

./configure  --with-tcl=/usr/local/lib/tcl8.6 --with-tclinclude=/usr/local/include/tcl8.6


Do a make. If all goes well, libpgtcl will be compiled and linked.


Do a make install


With version 1.4, Pgtcl is a standard package and can be loaded with "package require" instead of the shared library load routine, "load".

Fire up your tclsh:

% package require Pgtcl

It's a good idea to switch to using the package require instead of "load" to pick up Pgtcl, because there will be additional Tcl code shipped in future versions of Pgtcl, and using "package require" will make that code available to your application. Also it keeps you from hard-coding the path to the library and hard-coding a dependency on a specific version.


If it compiles and installs ok, but package require doesn't work, it probably didn't install into the search path Tcl uses to find extensions. You might have more than one Tclsh installed. Try adding a path to the parent directory of where the thing installed, for example, if it installed into /opt/local/bin

    % lappend auto_path /opt/local/lib
    % package require Pgtcl


Pgtcl was originally written by Jolly Chen. Many people have contributed to the development of Pgtcl over the years, including Randy Kunkee, who added the channel handler code, among many other improvements.

Karl Lehenbauer has been maintaining the software since 2002. Brett Schwartz contributed many improvements and bug fixes between 2002 and 2011. Jeff Lawson and Peter da Silva have made prolific contributions to Pgtcl since 2016. (Special thanks also to Peter for cleaning up and updating the documentation.)

Additional thanks to David McNett for the work to migrate Pgtcl from Tcl 8.4 to 8.5, and to Pietro Cerutti for ideas, assistance, and for maintaining the Pgtcl port for FreeBSD.

If you have contributed to Pgtcl at any time since its inception and your name is not listed here, please file an issue and we will gladly acknowledge your contribution.

You can’t perform that action at this time.