# Load mysqltcl's extensions.
load /usr/lib/mysqltcl-2.50/libmysqltcl2.50.so

# Create a variable that kind of represents your mysql connection (handler).
set mysql_db [mysqlconnect -host hostname -user youruser -password yourpass -db yourdb]

# Put your MySQL query in a variable.
set sql "INSERT INTO table VALUES ('yay', '$var', '[proc $var]')"

# Send the query to the MySQL server with [mysqlexec] (other procedures send queries also), and
# put the result (number of affected rows) in a variable.
set result [mysqlexec $mysql_db $sql]

# If no rows were affected (we couldn't insert the value in the table), output an error message
# and 'exit' the program.
if { $result != 1 } {
  puts "error: could not insert values into mysql table."
  return 0
}

# Free the memory space used by your MySQL handler.
mysqlclose $mysql_db