刷新 SWI-Prolog 中的数据库缓存
我们使用 swi-prolog 来运行我们的测试用例。每当测试开始时,我都会打开与 MYSQL 数据库的连接并存储正在完成的测试帽子的名称,然后关闭数据库。这些测试连续运行大约 2 天。测试完成后,结果基本上存储在服务器的文件夹中。另一个 prolog 文件中有一个谓词,调用该谓词将结果更新到 MYSQL 数据库。代码很简单,我使用 odbc 库,只需调用 odbc_* 谓词通过发出直接查询来连接和更新 mysql。
实际问题是:
- 如果我尝试从刚刚完成测试的同一个 Prolog 窗口调用谓词,则会在更新到数据库服务器时收到错误。虽然我在连接中没有收到任何错误。如果我使用
halt
关闭该 prolog 的会话并关闭所有打开的 prolog 窗口,然后打开 Prolog 的另一个完整的新实例并运行谓词,则更新会顺利进行。
我有一种感觉,Prolog数据库中有一些对MySQL DB的连接引用。有什么方法可以清除序言中的数据库,以便我可以运行相同的谓词而不关闭任何现有的序言窗口?
任何想法表示赞赏。
谢谢。
We are using swi-prolog
to run our testcases. Whenever the test starts, I am opening the connection to MYSQL database
and storing the Name of the Test hat is being done and then closing the DB. These tests run for about 2 days continuously. After the tests are done, the results basically gets stored in folder in the server. There is a predicate in another prolog file that is called to update the results to the MYSQL database. The code is simple, I use odbc
library and just call odbc_*
predicates to connect and update the mysql by issuing direct queries.
The actual problem is :
- If I try to call the Predicate from the same Prolog window, where the test just got completed, I get an error as updating to the DB server. Although I do not get any error in the connection. If I close the session of that prolog with
halt
and closing all the open prolog windows , then open an other complete new instance of Prolog and run the predicate the update goes well.
I have a feeling that there is some connection reference to the MySQL DB in Prolog database. Is there any way to clear the database in prolog so that I can run the same predicate without closing any existing prolog windows?
Any ideas appreciated.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您打开连接,而不是进行长时间处理,MySQL 可以在一定的超时后断开连接(我相信可以在
my.cnf
中配置)。编辑:swi-prolog 有一个 odbc_disconnect ,可用于在使用后显式关闭连接,还有一个“别名”模式,可用于在使用 odbc_open 时获取先前打开的连接/代码>。在这种情况下,您可以尝试在使用后关闭连接。打开时还应该避免使用别名。
If you open the connection, than do a long processing, MySQL can drop the connection in between after a certain timeout (that I believe can do configured in
my.cnf
).EDIT: swi-prolog has an
odbc_disconnect
that can be used to explicitly close the connection after using it and an "aliasing" mode that can be used to obtain a previously opened connection when usingodbc_open
. In you case you can try either closing the connection after using it. You should also avoid using an alias when opening.