日期:2014-05-16  浏览次数:20808 次

ActiveTCL的Mysqltcl学习笔记

1.包引入:

package require mysqltcl

?

2.中文乱码:

设置mysql数据库和数据表的字符集为gbk

连接数据库后设置系统参数mysqlexec $handle "SET NAMES 'gb2312'"

?

?

?

测试代码如下:

package require mysqltcl

set port 3306
set host 127.0.0.1
set user root
set password xxx

set mysql_handler [mysqlconnect -host $host -port $port -user $user -password $password]

mysqlexec $mysql_handler "SET NAMES 'gb2312'"

mysqluse $mysql_handler "test"

#mysqlexec $mysql_handler {insert into test values(NULL,'123中文','promotion',now(),1000,100,now(),now(),2)}

set res [mysqlsel $mysql_handler {select * from traffic} -list]

puts stdout $res

mysqlclose $mysql_handler
?