What: mysqltcl Where: http://freshmeat.net/projects/mysqltcl/ Homepage: http://www.xdobry.de/mysqltcl/index.html Description: Tcl interface to mysql relational database. Supports Tcl 8 objects, unicode, nested queries, etc. Currently at version 3.03. Updated: 4/2007 Contact: See web site ---- See also [MySQL]. ---- [SS]: 12Feb2005, I wrote this very short example of mysqltcl usage for a guy asking on the tclers chat how to use it. I'll put it here to redirect to this page the next people asking about it. The code connect to the mysql server at 'localhost', with username 'root', password 'foobar', select the database 'mysql', and try the query "SELECT HOST FROM USER". Every user returned is printed using puts, finally the mysql handle is closed. package require mysqltcl set m [mysqlconnect -user root -db mysql -password foobar] mysqluse $m mysql foreach res [mysqlsel $m {select host from user} -flatlist] { puts $res } mysqlclose $m 'Some comments about example' by [Artur Trzewik] 'mysqluse $m mysql' is not needed in this case because the database is already specified as connection parameter. The fastest solution in mysqltcl for fetching data (bigger volumes) is 'mysqlmap'. 'mysqlsel' with '-flatlist' will build a Tcl-List with whole result. For very big data-volumes the best chose is 'mysql::receive' that does not use client caching (on the level of mysqlclient C-library). Up from version 3.00 you can also use namespace command names. #using fetch mysql::sel $m {select host from user} while {[llength [set row [mysql::fetch $m]]]>0} { # row is always a list. using lindex avoids conversion list to string puts [lindex $row 0] } # the fastest way to operate data without building big internal Tcl lists. mysql::sel $m {select host from user} mysql::map $m host { puts $host } # for very big data volumes. No caching at all mysql::recieve $m {select host from user} host { puts $host } 'Mysqltcl and starkits' by DrumBSD I've found this code on a Mailing List to wrap mysqltcl for windows into a starkits o starpacks. You have to modify pkg_Index.tcl like this: proc loadmysqltcl { dir } { set oldcwd [pwd] cd $dir foreach file [glob *.dll] { file copy -force $file c:/winnt/temp } cd c:/winnt/temp load libmysqltcl[info sharedlibextension] cd $oldcwd } package ifneeded mysqltcl 3.01 [list loadmysqltcl $dir] Anyway, there's a problem when "c:/winnt/temp" doesn't exists. So I try to put a $tcl_platform(osVersion) into pkgIndex.tcl but it doesn't work. Maybe when it loads mysqltcl, tcl_platform array it doesn't exists. Any tips to solve this problem? [JH]: Did you make sure to declare tcl_platform global in the proc? [ramsan]: I think that all Windows have defined the variable TEMP. So: proc loadmysqltcl { dir } { set oldcwd [pwd] cd $dir foreach file [glob *.dll] { file copy -force $file $::env(TEMP) } cd $::env(TEMP) load libmysqltcl[info sharedlibextension] cd $oldcwd } package ifneeded mysqltcl 3.01 [list loadmysqltcl $dir] [Roalt Aalmoes] has made a simple tcl database engine called [adb] that uses this mysqltcl underneath. ---- [[ [Category Package] | [Category Database] ]]