On Wednesday, January 31, 2018 at 11:14:52 AM UTC-8, Max Farrar wrote: > > I have two scripts, one which maintains a connection to an SQLite3 db and > writes to it every minute, and a second script that maintains a connection > to that same SQLite3 db and reads from it every minute. > > The issue I'm having is that the script reading the db doesn't read the > values that are inserted after it makes it's initial connection. From > reading, this seems to be because SQLite3 reacts strangely when you try and > read while you have a writing connection open. > > Has anyone had experience with this?? The only workaround I've found is > using a connection block (so that the read script is actually > reconnecting), but I have to put a delay between the block ending and the > block reconnecting, otherwise the same problem occurs. I've read about > write-ahead logging and seeing if enabling that fixes the issue, but > unfortunately Sequel doesn't have a way to do that so I have to sort out > how to enable it manually... I haven't figured out how to do so, and I also > don't actually know if WAL would do anything. >
In general, if Sequel doesn't natively support a particular function of a driver, you should first figure out how to use the driver directly to accomplish what you want. In this case, that would be the ruby-sqlite3 driver (https://github.com/sparklemotion/sqlite3-ruby). Once you figure out how to use the underlying driver directly to accomplish what you want, you can make similar changes when using Sequel by using the :after_connect Database option: DB = Sequel.connect(..., :after_connect=>lambda do |conn| conn.enable_wal # or whatever code is needed end) Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
