PDA

View Full Version : call TCL script frm QT4.5



BalaQT
29th October 2009, 12:22
i have a TCL script to access SQLITE DB. Is it possible to call this script from QT?
if possible how can i call this script frm QT4.5?

proc populate_database {db {xtra_large 0}} {
execsql {
BEGIN;
CREATE TABLE t1(a, b);
INSERT INTO t1 VALUES(1, randstr(1000,1000));
INSERT INTO t1 SELECT a+ 1, randstr(1000,1000) FROM t1;
INSERT INTO t1 SELECT a+ 2, randstr(1000,1000) FROM t1;
INSERT INTO t1 SELECT a+ 4, randstr(1000,1000) FROM t1;
INSERT INTO t1 SELECT a+ 8, randstr(1000,1000) FROM t1;
INSERT INTO t1 SELECT a+16, randstr(1000,1000) FROM t1;
INSERT INTO t1 SELECT a+32, randstr(1000,1000) FROM t1;
CREATE INDEX i1 ON t1(b);
COMMIT;
} $db
if {$xtra_large} {
execsql { INSERT INTO t1 SELECT a+64, randstr(1000,1000) FROM t1 } $db
}
}


Thnks
Bala

high_flyer
29th October 2009, 17:47
If your script contains only valid sql statments and nothing else, you can just open it with QFile and load the get the script as a QString, and then you can feed it to your SQL code.

If the files contains also other stuff, I still think that parsing it should not be difficult.

BalaQT
30th October 2009, 09:43
thnks fr ur reply high_flyer

My script will contain, SQLSTATEMTNTS , IF ,ELSE block,other stuffs too. i just want to execute the script from QT

Thnks
Bala

high_flyer
30th October 2009, 13:17
Again, if the file contains only valid SQL code, then you can just load it and pass it as a QString.
If not, you will have to parse it.