读取 Sqlite 数据库的 Tcl Starkit
我正在尝试构建一个读取 Sqlite 数据库的 Tcl 应用程序。当我为应用程序构建 starkit 并将 Sqlite 数据库文件放在 .vfs 文件夹中的 .tcl 文件旁边并尝试运行应用程序 (.exe) 时,我收到错误“执行时找不到包 sqlite3”包需要 sqlite3”。
我相信我的应用程序无法找到数据库文件。在构建 starkit 之前,.tcl 应用程序能够读取 Sqlite 数据库,但是在创建 starkit 后,.tcl 文件出现错误。
有谁知道如何使 Tcl 应用程序 starkit 读取 Sqlite 数据库文件?
谢谢,
东风公司
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为你的starkit更有可能无法加载sqlite3包。您是否在 .vfs 文件夹中创建了 lib 目录并将 sqlite3 包复制到其中?
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?
听起来您在问题中讨论了两件不同的事情。
第一个是加载 sqllite3 库的能力。正如 Jackson 所指出的,您需要将 sqllite3 库(tcl 和随附文件)包含在 starpack 的 lib 目录中。一旦正确完成,“package required sqlite3”命令应该可以正常工作。
第二个是关于-writable标志。如果我理解正确的话,这只允许您在 starpack 运行时修改其内的文件。它与加载 starpack 中包含的库的能力无关,但可用于允许该库修改文件(例如您谈到的数据库文件)。
我的印象是,由于某些操作系统的限制,不可能写入正在运行的starkit(内部的文件)。话虽这么说,我从 Brent Welch 的精彩著作《Tcl 和 Tk 中的实用编程》中发现了以下内容:
参考:Google 图书
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":
Referece: Google Books
在回答我的问题的每个人的帮助下以及一些深入的研究,我找到了创建一个starpack的步骤,该starpack用Sqlite后端包装了Tcl应用程序。创建starpack的步骤如下:
下载并放入文件夹
tclkit-win32.upx.exe
和sdx.kit
。复制
tclkit-win32.upx.exe
并将其重命名为tclkit.exe
(保留在同一文件夹中)添加您的 .tcl (
test.tcl< /code>)应用程序添加到该文件夹(确保它具有代码
package require sqlite
。运行
tclkit-win32.upx.exe
文件并每行键入以下内容(不要关闭完成后):下载
tclsqlite3.dll< /code> 来自 sqlite 网站并放置在单独的文件夹中。将文件夹命名为
sqlite
。使用记事本等文本应用程序并添加以下代码:
另存为
pkgIndex.tcl
并将其与tclsqlite3.dll
一起放入 sqlite 文件夹中。进入第一步中的第一个文件夹。您应该会看到一个 .vfs 文件夹。打开 .vfs 文件夹,然后打开 lib 文件夹。将 sqlite 文件夹放在 lib 文件夹中。 lib 文件夹应该有一个 app-test 文件夹(对应于
test.tcl
)和您的 sqlite 文件夹。<块引用>
步骤 5-7 的替代方法:将包含 sqlite dll 的文件夹从 C:\ 上的 tcl 文件夹复制到 lib 文件夹中。您可以使用
验证 dll 的路径
sqlite 文件夹将包含两个文件,即 dll 文件和
pkgIndex.tcl
。如果您这样做,则必须在步骤 3 中使用package require sqlite3
。在
tclkit-win32.upx.exe
仍在运行的情况下,键入以下代码:最后,将 sqlite .db 文件放在新创建的应用程序 .exe 旁边(test.exe) 并运行应用程序。
请务必注意版本冲突。我在
package require sqlite
代码片段方面遇到了重大问题。最初,我有package require sqlite3
,但它不起作用。另外,当您创建pkgIndex.tcl
文件时,请确保具有正确的 sqlite 版本(即 3.2.18 等)。感谢大家的帮助。
直接制造
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:
Download and place in a folder
tclkit-win32.upx.exe
andsdx.kit
.Make a copy of the
tclkit-win32.upx.exe
and rename it totclkit.exe
(leave in same folder)Add your .tcl (
test.tcl
) application to the folder (make sure that it has the codepackage require sqlite
.Run the
tclkit-win32.upx.exe
file and type the following per line (do not close when done):Download
tclsqlite3.dll
from the sqlite website and place in a separate folder. Name the foldersqlite
.Use a text app like Notepad and add the following code:
Save as
pkgIndex.tcl
and place in the sqlite folder with thetclsqlite3.dll
.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.With
tclkit-win32.upx.exe
still running, type the following code: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 hadpackage require sqlite3
, which wasn't working. Also, when you create thepkgIndex.tcl
file, make sure to have the correct version of sqlite (i.e. 3.2.18, etc...).Thank you for everyone's assistance.
DFM