Version 4 of Linking Bwise with PostgreSql

Updated 2009-04-16 22:51:04 by theover

TV Because for non-Tcl reasons ([L1 ], [L2 ]) I recently looked PostgreSQL, I rethought the thought I had many years ago, that bwise and a good database could make a good combination.

So I looked at pgacces ([L3 ] moved to pgfoundry) which requires a compile while I want to make a easy to use also windows front end, and pgintcl [L4 ] which is written in Tcl and should do the trick.

So I installed the latter in Tcl/lib, the package require worked, and after setting some permissions on the local net I could access my (web, file and otherwise) Server/TV/Video/HD edit station from the example script from pgintcl. The fedora 8/64 based postgress server resonded normal, while wiki access and web site indexer sql databases continued to function normal. So far so good.

To test with katest version pgintcl:

 source tkpsql.tcl
 # requires pgin.tcl in the same dir it seems

http://82.171.148.176/Wiki/bwsql1.gif

The data base should have been created with a user with rights to do what you want and login rightd (see pg_sql docu) and the password must be in some system file in the postgres installation directory, just like for like in this case a login on another machine requires a .conf file edit.

Using some special buttons the output is:

 List Databases
 OK with 6 rows and 2 columns.

 Database Name Owner
 postgres      postgres
 abcd          postgres
 template0     postgres
 template1     postgres
 test          postgres
 wikidb        wikiuser

 List Tables
 OK with 1 row and 3 columns.

 Schema Table      Owner
 public table_name zyx

 List Users
 OK with 3 rows and 3 columns.

 Username User-ID Rights
 zyx      76543   
 postgres 7865     Superuser, Create Database, Update Catalogs
 wikiuser 0987   

If you have a console window:

 % array get dbinfo
 has_schema 1 port 5432 host 192.168.0.1 password pass dbname test user zyx
 % run_sql "select * from table_name"

will put the result in the upper window.

Lets test a small computation aimed example, first through the run sql window:

 create table squares (
 n int,
 sq varchar(20)
 )

then from the tcl prompt:

 for {set x 0} {$x <= 100} {incr x} {
     run_sql "insert into squares values ($x, [expr $x*$x])" 
 }

Now from sql:

 select * from squares

gets a list of number to 100 and their squares from the database, good. Getting results is a little bit of a haggle with the database driver routines it seems, results must be gotten per row.


enter categories here