TDBC is a lot smarter than that. It verifies the connection every time you
attempt to use it for something. My helper looks something like this:
proc getDbConnection {args} {
if {[info commands ::db] ne ""} {
## Already have a connection.
if {![catch {::db configure {*}$args} error]} {
return
}
::db close
}
tdbc::mysql::connection create ::db {*}$args
}
Every request calls this proc which attempts to configure the connection each
time. I assume that the arguments passed in are legal, so if the connection
fails to configure for some reason, it will just destroy it and make a new one.
This is usually because the db connection has been live for a long time and
has lost connection to the server somehow.
The other nice thing about this setup is that you can have multiple sites using
the same children, and the DB proc here will simply reconfigure the db
connection to a new user / host / database with each request if needed. Which
is almost as expensive as just creating a new connection every time, so I
prefer to use separate virtual interps per host, but hey, it works! 0-]
D
On Oct 29, 2010, at 11:13 AM, Massimo Manghi wrote:
> I don't know which backend you are using, but I had a few problems working
> with mysqltcl. As one might expect, if a child process stays idle too long
> the backend drops the connection, and it happened every night on the computer
> where I was developing the application.
>
> mysqltcl has a 'status' method and I thought I could have information about
> the dbms connection from it, but actually it didn't say anything useful (what
> it returned was even wrong and misleading). This was a few years ago and this
> support in mysqltcl might have improved now.
>
> The only way I found to get around it was closing the connection once the
> request had been served and reopening it every time. Shamefully expensive.
>
> -- Massimo
>
> On 10/29/2010 06:57 AM, Clif Flynt wrote:
>>
>> Thanks. I was suspecting something like this.
>>
>> Eventually, all of the children will have a ::db1 procedure, and
>> all will be happy.
>>
>> I was afraid that I was causing some unnecessary thrashing, but I
>> guess it's necessary after all.
>>
>> Happy Tcl'ing,
>> Clif
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]