views:

341

answers:

3

Hello:

I am trying to build a Tcl Application that reads off of a Sqlite database. When I build a starkit for the application and place the Sqlite database file next to the .tcl file within the .vfs folder and try to run the application (.exe), I receive the error, "can't find package sqlite3 while executing package require sqlite3".

I believe my application is unable to find the database file. Before building the starkit, the .tcl application is able to read the Sqlite database, but after I create the starkit, the .tcl file gets the error.

Does anyone know how to enable a Tcl application starkit to read a Sqlite database file?

Thanks,

DFM

+3  A: 

I think that it is more likely that your starkit can't load the sqlite3 package. Have you created a lib directory in your .vfs folder and copied the sqlite3 package into it?

Jackson
Hello Jackson - Thanks for the reply. I only tried to wrap the .db file with the .tcl file within the .vfs folder. I'll create a lib directory and go from there. I saw somewhere that I might have to include -writable when I wrap my application. Does this sound familiar to you?
DFM
+3  A: 

It sounds like you're discussing two different things in your question.

The first is the ability to load the sqllite3 library. As noted by Jackson, you'll need to include the sqllite3 library (tcl and accompanying files) in the lib directory of your starpack. Once that is done correctly, the "package required sqlite3" command should work correctly.

The second is in regards to the -writable flag. If I'm understanding correctly, that just allows you to modify files within the starpack while it's running. It has nothing to do with the ability to load a library included in the starpack, but would be used to allow that library to modify files (like the database file you talked about).

I was under the impression that it wasn't possible to write to a (a file inside a) starkit that is running, due to certain OS constraints. That being said, I found the following from Brent Welch's amazing book "Practical programming in Tcl and Tk":

If you run the write.kit file more than once you will notice that the write.kit/data.new file not persist between runs. This is because, by default, the Metakit database is modified in main memory and it is not written out to the Starkit file. if you want to store file long term, use the -writable flag to sdx:

sdx wrap write.kit writable

Referece: Google Books

RHSeeger
Hello RHSeeger - Thanks for the reply. I actually have that book. I saw that excerpt, but I don't know if it applies to what I am trying to do. I need to place a .db file (sqlite) somewhere in my starkit so that the code snippet "package required sqlite3" doesn't throw an error. I unwrapped my starkit and found a lib directory within the .vfs folder, and then I tried placing the .db file in different variations within the folder, however to no avail. I don't know if I have to add more code to the .tcl file, change the .db file extension, create a specfic folder in the lib folder, etc...
DFM
Edited my answer to address your comment.
RHSeeger
I downloaded a tclsqlite3.dll file from sqlite's website. I believe this is the file that needs to be placed in the starpack lib directory. I guess I do not understand where this file needs to be located. The .vfs lib folder has the following folders: dde, itcl3.4, Itcl, rechan, registry, tcl8, tcl8.5 thread2.6.5, tk8.5, vfs1.3, and zlib. I tried creating a new folder (sqlite3), as well as placing the tclsqlite3.dll file in the listed folders. After re-wrapping, I tried running the app, but I got the same error. I really appreciate your comments; thank you.
DFM
There really should be more to what you got from their web site. I would think there would be a directory structure with a number of files. You want to put the entire directory in your vfs lib folder. At the very least, there should be a pkgIndex.tcl file that came with it.
RHSeeger
A: 

Hello:

With the help of everyone who replied to my question and some thorough research, I figured out steps to create a starpack that wraps a Tcl App with a Sqlite back-end. The steps to create the starpack are as follows:

  1. download and place in a folder tclkit-win32.upx.exe and sdx.kit
  2. Make a copy of the tclkit-win32.upx.exe and rename it to tclkit.exe (leave in same folder)
  3. Add your .tcl (test.tcl) application to the folder (make sure that it has the code "package require sqlite".
  4. Run the tclkit-win32.upx.exe file and type the following per line (do not close when done): source sdx.kit, package require sdx, sdx::sdx qwrap test.tcl, sdx::sdx unwrap test.kit
  5. download tclsqlite3.dll from the sqlite website and place in a separte folder. Name the folder sqlite.
  6. Use a text app like Notepad and add the following code: package ifneeded sqlite 3.6.18 [list load [file join $dir tclsqlite3.dll]]. Save as pkgIndex.tcl and place in the sqlite folder with the tclsqlite3.dll.
  7. Go into your first folder in step one. You should see a .vfs folder. Open the .vfs folder, and then open the lib folder. Place the sqlite folder in the lib folder. The lib folder should have a app-test folder (corresponds with test.tcl) and your sqlite folder.
  8. With tclkit-win32.upx.exe still running, type the following code: sdx::sdx wrap test.exe -runtime tclkit.exe
  9. Lastly, place your sqlite .db file next to your newly created application .exe (test.exe) and run the app.

Make sure to watch for version conflicts. I had major problems with the "package require sqlite" code snippet. Originally, I had "package require sqlite3", which wasn't working. Also, when you create the pkgIndex.tcl file, make sure to have the correct version of sqlite (i.e. 3.2.18, etc...).

Thank you for everyone's assistance.

DFM

DFM
Ah, so you wound up creating the pkgIndex.tcl file manually. As a side note, it's generally considered polite to give a +1 to the people that provided useful answers to you.
RHSeeger