I'm running a very basic Sinatra server, which simply shows a Chartkick graph of some data I have through the Sequel gem. I'm noticing that the data on the chart doesn't seem to update unless I quit the Sinatra server script and rerun it. 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?
我正在运行一个非常基本的Sinatra服务器,它只显示了我通过Sequel gem获得的一些数据的Chartkick图。我注意到图表上的数据似乎没有更新,除非我退出Sinatra服务器脚本并重新运行它。我真的不明白这是怎么可能的......我在使用Sequel阅读我的数据库时使用的唯一非正常的选项是只读选项..会导致这个吗?
1 个解决方案
#1
0
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开始,可以使用新的“Write Ahead Logging”(WAL)选项,其中读取和写入可以同时进行。
By default, WAL is not enabled. To turn WAL on, refer to the SQLite documentation.
默认情况下,WAL未启用。要打开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. I worked around this issue by using a block connection in my Sinatra script. I don't know how to turn on WAL with Sequel though...
我目前有脚本A,它维护与DB文件的连接并定期写入它,脚本B,这是我的Sinatra服务器,从该DB文件读取信息。我在Sinatra脚本中使用块连接解决了这个问题。我不知道如何用续集开启WAL ...
#1
0
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开始,可以使用新的“Write Ahead Logging”(WAL)选项,其中读取和写入可以同时进行。
By default, WAL is not enabled. To turn WAL on, refer to the SQLite documentation.
默认情况下,WAL未启用。要打开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. I worked around this issue by using a block connection in my Sinatra script. I don't know how to turn on WAL with Sequel though...
我目前有脚本A,它维护与DB文件的连接并定期写入它,脚本B,这是我的Sinatra服务器,从该DB文件读取信息。我在Sinatra脚本中使用块连接解决了这个问题。我不知道如何用续集开启WAL ...