原创文章,转载请注明: 转载自勤奋的小青蛙
本文链接地址: Tcl与mysql连接(mysqltcl使用)

Mysqltcl is a simple API for Mysql-Database and Tcl script language.

In order to connect to mysql in Tcl programming, we can choose mysqltcl. Mysqltcl is on this website: of us can get it on this site.

For mysqltcl, it has version on windows and Linux. Today i just give the usage on windows 7.

1: install ActiveTcl and mysql server on windows.

install ActiveTcl can reference this blog:

install mysqlserver can reference this site:

2:when mysql have installed, the server user:root and password:root, I create a database "blog" and it has table "user" and table "user" has one record: "name":"ypf", "password":"ypf", "id":"1".

3:download mysqltcl for windows and install it.

mysqltcl download page:

I use the latest

how to install it? very easy, unzip the file in your Tcl/lib dictonary. (default C:/Tcl/lib dependent on your Tcl install path).

4: Programming tcl and connect to mysql and query table "user" with sql language "select * from user;"


package require mysqltcl
set m [mysqlconnect -user root -db blog -password root]
mysqluse $m blog
foreach res [mysqlsel $m {select * from user} -list] {
 puts "name is [lindex $res 0]"
 puts "pass is [lindex $res 1]"

then in cmd I can execute the tcl with tclsh:

all the mysqltcl API at here:

you can also get more info at:

原创文章,转载请注明: 转载自勤奋的小青蛙
本文链接地址: Tcl与mysql连接(mysqltcl使用)




:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: