读取 Sqlite 数据库的 Tcl Starkit

发布于 2024-08-04 21:47:00 字数 321 浏览 3 评论 0原文

我正在尝试构建一个读取 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

山色无中 2024-08-11 21:47:00

我认为你的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?

甜妞爱困 2024-08-11 21:47:00

听起来您在问题中讨论了两件不同的事情。

第一个是加载 sqllite3 库的能力。正如 Jackson 所指出的,您需要将 sqllite3 库(tcl 和随附文件)包含在 starpack 的 lib 目录中。一旦正确完成,“package required sqlite3”命令应该可以正常工作。

第二个是关于-writable标志。如果我理解正确的话,这只允许您在 starpack 运行时修改其内的文件。它与加载 starpack 中包含的库的能力无关,但可用于允许该库修改文件(例如您谈到的数据库文件)。

我的印象是,由于某些操作系统的限制,不可能写入正在运行的starkit(内部的文件)。话虽这么说,我从 Brent Welch 的精彩著作《Tcl 和 Tk 中的实用编程》中发现了以下内容:

如果您多次运行write.kit文件,您会注意到write.kit/data.new文件在运行之间不会保留。这是因为,默认情况下,Metakit 数据库是在主内存中修改的,并且不会写入 Starkit 文件中。如果您想长期存储文件,请使用 sdx 的 -writable 标志:

sdx 包装 write.kit 可写

参考: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":

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

谁人与我共长歌 2024-08-11 21:47:00

在回答我的问题的每个人的帮助下以及一些深入的研究,我找到了创建一个starpack的步骤,该starpack用Sqlite后端包装了Tcl应用程序。创建starpack的步骤如下:

  1. 下载并放入文件夹tclkit-win32.upx.exesdx.kit

  2. 复制 tclkit-win32.upx.exe 并将其重命名为 tclkit.exe(保留在同一文件夹中)

  3. 添加您的 .tcl (test.tcl< /code>)应用程序添加到该文件夹​​(确保它具有代码 package require sqlite

  4. 运行tclkit-win32.upx.exe文件并每行键入以下内容(不要关闭完成后):

    源 sdx.kit
    包需要 sdx
    sdx::sdx qwrap 测试.tcl
    sdx::sdx 解包 test.kit
    
  5. 下载tclsqlite3.dll< /code> 来自 sqlite 网站并放置在单独的文件夹中。将文件夹命名为 sqlite

  6. 使用记事本等文本应用程序并添加以下代码:

    package ifneeded sqlite 3.6.18 [list load [file join $dir tclsqlite3.dll]]。
    

    另存为 pkgIndex.tcl 并将其与 tclsqlite3.dll 一起放入 sqlite 文件夹中。

  7. 进入第一步中的第一个文件夹。您应该会看到一个 .vfs 文件夹。打开 .vfs 文件夹,然后打开 lib 文件夹。将 sqlite 文件夹放在 lib 文件夹中。 lib 文件夹应该有一个 app-test 文件夹(对应于 test.tcl)和您的 sqlite 文件夹。

    <块引用>

    步骤 5-7 的替代方法:将包含 sqlite dll 的文件夹从 C:\ 上的 tcl 文件夹复制到 lib 文件夹中。您可以使用

    验证 dll 的路径

     package ifneeded sqlite3 [package require sqlite3]
    

    sqlite 文件夹将包含两个文件,即 dll 文件和 pkgIndex.tcl。如果您这样做,则必须在步骤 3 中使用 package require sqlite3

  8. tclkit-win32.upx.exe 仍在运行的情况下,键入以下代码:

    sdx::sdx 包装 test.exe -runtime tclkit.exe
    
  9. 最后,将 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:

  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 separate 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.

    Alternative to steps 5-7: copy the folder containing the sqlite dll from the tcl folder on C:\ into the lib folder. You can verify the path of the dll by using

      package ifneeded sqlite3 [package require sqlite3]
    

    The sqlite folder will have two files, the dll file and a pkgIndex.tcl. If you do it this way, you have to use package require sqlite3 in step 3.

  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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文