sqlitetcl

invalid command name "sqlite3" in tcl script from sqlite docs (Wapp Application Error)


I want to be able to use sqlite docs offline. I was glad this site https://www.sqlite.org/2023/sqlite-doc-3430000.zip had zip file with html docs. Zip even contained search file which turned out to be tcl script having: #!/usr/bin/tclsh.docsrc...package require Tcl 8.6; running as is failed, but I realized I do have /usr/bin/tclsh8.6. However now after tclsh ./search I've got in my browser

Wapp Application Error

invalid command name "sqlite3" while executing "sqlite3 db [file dir [wapp-param SCRIPT_FILENAME]]/search.d/search.db" (procedure "wapp-default" line 39) invoked from within "wapp-default"

Interestingly:

~/Downloads/sqlite-doc-3430000$ echo sqlite3 | tclsh
invalid command name "sqlite3"
~/Downloads/sqlite-doc-3430000$ tclsh
% sqlite3
SQLite version 3.37.2 2022-01-06 13:25:41
~/Downloads/sqlite-doc-3430000$ echo parray | tclsh
wrong # args: should be "parray a ?pattern?"

But I've noted second case just likely runs an external CLI commands.

How to install "sqlite's standard Tcl frontend, which gives you full Tcl and comes with Tcl distributions" (https://www.sqlite.org/tclsqlite.html), which was in the answer of Sqlite (within SqliteStudio): invalid command name "parray"? Any other ideas about cause of the error?

Added:

Web searching found some new related to tcl advice, after apt-get install libsqlite3-dev / libsqlite3-tcl / tcl-dev still no sqlite3 command.

Added:

After comment by @mrcalvin + reading https://www.tcl.tk/community/tcl2004/Presentations/D.RichardHipp/slides/slides-all.html I tried to add package require sqlite3 to "search" file and page opened. However after trying to use it I got (see below). Seems to me the code is not up-to-date or else. Don't know where to file a bug report...

Wapp Application Error

no such tokenizer: stoken while executing "db eval $sql" (procedure "searchresults" line 31) invoked from within "$cmd" ("uplevel" body line 1) invoked from within "uplevel {$cmd}" invoked from within "time [list uplevel $script]" (procedure "ttime" line 2) invoked from within "ttime {$cmd}" invoked from within "db transaction { set t [ttime {$cmd}] }" (procedure "wapp-default" line 46) invoked from within "wapp-default"


Solution

  • Before using the Tcl commands of the tclsqlite extension, you need to source the corresponding Tcl package:

    1. Enter your Tcl shell:

    $ tclsh
    
    1. Enter the following Tcl command:

    % package req sqlite3
    3.42.0
    
    1. Test the presence of tclsqlite commands:

    % info commands sqlite3
    sqlite3
    % sqlite3 db1 :memory:
    % db1 eval {select sqlite_version();}
    3.42.0
    % db1 close