Check that it is safe to write.
SQLite is not threadsafe for concurrent _writes_ unless the
underlying sqlite library was built with thread safety
enabled. Even still, it may be a good idea to use a thread
lock (@with_thread_lock) to prevent parallel writes.