在tcl数据库中插入值

时间:2015-01-03 07:40:01

标签: tcl

我在tcl:

中向此数据库添加内容时遇到问题
  set fd [open country.txt]
  set content [read $fd]
  close $fd
  set qcontent [string map {' ''} $content]
  db eval "INSERT INTO t1 VALUES(1,2,'$content')"

仍然没有添加请求的值。

2 个答案:

答案 0 :(得分:1)

你应该使用大括号来避免处理单引号:

set fd [open country.txt]
set content [read $fd]
close $fd
db eval {INSERT INTO t1 VALUES(1,2,$content)}

既然你不需要逃避单引号,你就会减少变量并减少错误。

答案 1 :(得分:0)

db eval "INSERT INTO t1 VALUES(1,2,'$qcontent')"

应该是要评估的qcontent变量。

相关问题