Version 13 of Quick-start guide to use of PostgreSQL with Tcl

Updated 2004-11-20 01:54:06

PostgreSQL and Tcl combine quite pleasantly. It can be a delight using them for substantial development projects. Much the more demanding, at least in setup, is the former. Here's what it takes to start: ... [to be finished]


Ugh. I'm left hanging in anticipation...

Seriously, this is a problem I have right now. If the original author (or anybody else) wants to add to this page, it would be *greatly* appreciated.


1. Setup PostgreSQL

Either just install your OS specific package if it is available for example the postgreSQL rpm, or start reading the fine postgreSQL install instructions at: http://www.postgresql.org/docs/7.4/interactive/installation.html

Make sure you have a running server, get its connection info like hostname, port, user and password for the user you want to use for the next steps.

2. Make sure you have a working Pgtcl package

Try:

 package require Pgtcl

If it works, you have a probably working Pgtcl package installed, otherwise you need to install/compile one from either the PostgreSQL distribution you have installed (Pgtcl should be included there) or obtain and build libpgtcl.

3. Start using Pgtcl

Take a look at: http://www.postgresql.org/docs/7.4/interactive/pgtcl.html

The basics:

 # open connection
 # password etc. must be provided according to the security settings on the postgres db
 #
 set db [pg_connect -conninfo [list host = localhost user = test dbname = testdb]

 set resultObj [pg_execute $db {SELECT * FROM testtable;}

 puts "Nr of result rows: [pg_result $resultObj -numTuples]"

 # cleanup the resultObj
 pg_result $resultObj -clean

 # close the connection

 pg_disconnect $db