简体   繁体   English

Sinatra + Chartkick + Sequel gem,图表未更新

[英]Sinatra + Chartkick + Sequel gem, chart not updating

I'm running a very basic Sinatra server, which simply shows a Chartkick graph of some data I have through the Sequel gem. 我正在运行一个非常基本的Sinatra服务器,该服务器仅显示了通过Sequel gem获得的一些数据的Chartkick图。 I'm noticing that the data on the chart doesn't seem to update unless I quit the Sinatra server script and rerun it. 我注意到,除非我退出Sinatra服务器脚本并重新运行它,否则图表上的数据似乎不会更新。 I don't really understand how that would be possible... the only non-normal thing option I'm using when reading my database using Sequel is the read-only option.. would that cause this? 我真的不太明白这是怎么可能的...使用Sequel读取数据库时,我使用的唯一非正常的选项是只读选项..这会导致这种情况吗?

It turns out, from reading another post on here: 事实证明,从这里阅读另一篇文章:

First, by default, multiple processes can have the same SQLite database open at the same time, and several read accesses can be satisfied in parallel. 首先,默认情况下,多个进程可以同时打开同一个SQLite数据库,并且可以并行满足多个读取访问权限。

In case of writing, a single write to the database locks the database for a short time, nothing, even reading, can access the database file at all. 在写入的情况下,对数据库的单次写入将在短时间内锁定数据库,即使读取也无法访问数据库文件。

Beginning with version 3.7.0, a new “Write Ahead Logging” (WAL) option is available, in which reading and writing can proceed concurrently. 从3.7.0版开始,提供了一个新的“预先写入日志”(WAL)选项,在其中可以同时进行读取和写入。

By default, WAL is not enabled. 默认情况下,不启用WAL。 To turn WAL on, refer to the SQLite documentation. 要打开WAL,请参考SQLite文档。

I currently have script A, which maintains a connection to the DB file and writes to it regularly, and script B, which is my Sinatra server that reads information from that DB file. 我目前有脚本A和脚本B,脚本A维护与数据库文件的连接并定期对其进行写入,而脚本B是我的Sinatra服务器,该服务器从该数据库文件中读取信息。 I worked around this issue by using a block connection in my Sinatra script. 我通过在Sinatra脚本中使用块连接来解决此问题。 I don't know how to turn on WAL with Sequel though... 我不知道如何用Sequel打开WAL ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM