This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Pls help me with sql in tcl ...

Old posts that have not been replied to for several years.
Locked
t
tff2

Pls help me with sql in tcl ...

Post by tff2 »

Hello mates...

I really dont have any knowledge of SQL ... in TCL i already can do many things... but sql is like a book with 7 seals ...

I want to grab a text, insert that in a sql-database with date and time, and i want to be able to read this text and see the date and time ...

Something like a "pre-time-logger" ... hope you can help me :)
User avatar
Dereckson
Voice
Posts: 20
Joined: Thu May 30, 2002 8:00 pm
Location: Belgium
Contact:

Post by Dereckson »

First, you have to install something to allow tcl to play with sql databases.

In my mind, the most powerful and easy is fbsql : http://www.fastbase.co.nz/fbsql/index.html

---

Secondly, you have to create a table with two columns : one for the timestamp (for example called datetime), another for the text (for exemple called text)

Do you have phpMyAdmin on the server you use or do you need explanations to use mysql directly from a shell or is it installed on your personnal computer ?

---

Finally, the scripts.

To initialize fbsql :

Code: Select all

load ./fbsql.so
To insert a text in database, one line is enough :

Code: Select all

sql "INSERT INTO theNameOfYourTable (datetime, text) VALUES ('[unixtime]', '$text')" where $text is a parameter of the proc.
Finally, to read ALL the text (it's possible to filter) :

Code: Select all

#First, create a list with all the rows :
set allText [sql "SELECT datetime, text FROM theNameOfYourTable"]
#Then, print each row :
foreach text $allText {
	#text is a list with one element per row
	#Read the timestamp
	set timestamp [strftime "%d/%m %R" [lindex $text 0]]
	putdcc $idx "<$timestamp> [lindex $text 1]"
}
Sébastien Santoro
Locked