Re: using TCL with sqlite database...



Actually, the line

write_sqlite_db { "t_test" "some data" }

should give you a syntax error, since your write_sqlite_db takes two
arguments. You probably meant

write_sqlite_db "t_test" "some data"

Can it be that you have a "catch" somewhere which hides the error message?

Also, sqlite probably doesn't allow you to use a variable as table name
in the insert statement. You could instead try

proc write_sqlite_db {table val} {
testdb eval "insert into $table values(\$val)"
}

On the other hand that is much more inefficient since you're then
re-parsing the sql-statement on each execution.

Jan Van Belle wrote:
Hello all,

I'm trying to access an SQLite database via TCL.
Creating/opening/create tables etc. succeeds when doing it in 1 procedure,
but fails when I open the db in proc open_sqlite_db {} and try to write
to it in proc write_sql_db {}

example code:

proc general_calling_procedure {} {
# sqlite library is already loaded...

open_sqlite_db
write_sqlite_db { "t_test" "some data" }
...
}

proc open_sqlite_db {} {
sqlite testdb "./my_example.db"
testdb eval { create table t_test ( dummy varchar(30) ) }
}

proc write_sqlite_db { table data } {
testdb eval { insert into $table values($data) }
}

####

If I read back the data which should have been written, there is
just nothing... Quite frustrating...
Most probably it has nothing to do with sqlite itself, just the way to
access the command 'testdb'.
That's the reason why I first try it here...

Kind regards,

Jan


--
=> Christian Nassau, http://www.nullhomotopie.de


.



Relevant Pages

  • Re: using TCL with sqlite database...
    ... I'm trying to access an SQLite database via TCL. ... Creating/opening/create tables etc. succeeds when doing it in 1 procedure, ... but fails when I open the db in proc open_sqlite_db and try to write ...
    (comp.lang.tcl)
  • using TCL with sqlite database...
    ... I'm trying to access an SQLite database via TCL. ... Creating/opening/create tables etc. succeeds when doing it in 1 procedure, ... but fails when I open the db in proc open_sqlite_db and try to write ...
    (comp.lang.tcl)
  • Re: using TCL with sqlite database...
    ... which fails and ... ... should give you a syntax error, ... Can it be that you have a "catch" somewhere which hides the error message? ... sqlite probably doesn't allow you to use a variable as table name ...
    (comp.lang.tcl)
  • do not understand this closure
    ... proc ... :10: syntax error ...
    (comp.lang.ruby)