Home > Archive > Tcl > November 2006 > mysqltcl tips?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| dinkalopogis@gmail.com 2006-11-20, 7:08 pm |
| I am looking for a couple of examples with regard to mysqltcl.
What I am trying to do is pull a bunch of information out of mysql and
use it in tcldot.
I can manually make tcldot work can and also pull data manually out of
mysql.
But I get all sorts of brackets, and seem to be having a hard time
getting rid of them from the mysqltcl pull.
Looking for some examples on this if anyone has some.
Thanks
| |
|
| dinkalopogis@gmail.com <dinkalopogis@gmail.com> wrote:
> I am looking for a couple of examples with regard to mysqltcl.
# Set connection if you need to.
if {![info exists MYSQL_LINK] || [::mysql::state $MYSQL_LINK -numeric] < 3 } {
if {[catch {::mysql::connect -user "$user" -password "$pass" -host \
"$host" -db "$database" -port "$port" -compress "$compress"} result]} { puts "Connection error." }
}
# Tell MySQL you want it all
::mysql::sel $MYSQL_LINK "SET OPTION SQL_BIG_SELECTS=1" -flatlist
# Run a query, do something with the result.
set DATA [::mysql::sel $MYSQL_LINK "SELECT id,ct FROM table WHERE date > '2005-01-01' ORDER BY id" -list]
foreach {item} $DATA {
set id [lindex $item 0] ; set ct [lindex $item 0]
puts "id: $id, ct: $ct"
}
> What I am trying to do is pull a bunch of information out of mysql and
> use it in tcldot.
>
> I can manually make tcldot work can and also pull data manually out of
> mysql.
>
> But I get all sorts of brackets, and seem to be having a hard time
> getting rid of them from the mysqltcl pull.
Sounds like either a -list/-flatlist choice problem (or perhaps you're
not using your data as a list).
| |
|
| Synic <flavp+hfrarg@nhgbaf.arg.nh> wrote:
> set id [lindex $item 0] ; set ct [lindex $item 0]
Oops! Should be:
set id [lindex $item 0] ; set ct [lindex $item 1]
| |
| dinkalopogis@gmail.com 2006-11-28, 4:06 am |
|
Thanks for the helpj.
I did not realize it was in string form.
|
|
|
|
|