Skip to content

Bounty: Help with multiple processes #522

Closed Answered by gottlike
gottlike asked this question in Q&A
Discussion options

You must be logged in to vote

Okay, so I found an answer, which is pretty simple (thankfully):

# frozen_string_literal: true

require 'json'
require 'parallel'
require 'sqlite3'

module DB
  @db = SQLite3::Database.new('test.db')
  @db.execute('PRAGMA journal_mode = WAL')
  @db.execute('PRAGMA synchronous = normal')
  @db.execute('PRAGMA temp_store = memory')
  @db.execute('PRAGMA mmap_size = 30000000000')
  @db.execute('PRAGMA busy_timeout = 5000')
  @db.execute('CREATE TABLE IF NOT EXISTS everything (id TEXT UNIQUE, data BLOB)')

  def self.set(id, type, data)
    import = { type: }.merge(data)
    @db.execute('INSERT OR REPLACE INTO everything (id, data) VALUES (?, jsonb(?));', "#{type}/#{id}", import.to_json)
  re…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gottlike
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant