class BBS::SQLite

One SQLite file of a board and its one connection, shared by the callers’ threads behind a lock. The file is opened in WAL mode, so a second process (a command-line tool of the board) can read and write it meanwhile, with foreign keys on.

DB = BBS::SQLite.new('data/board.sqlite3')
DB.migrate(
  'CREATE TABLE posts (id INTEGER PRIMARY KEY, title TEXT NOT NULL)',
  'ALTER TABLE posts ADD COLUMN body TEXT'
)
id = DB.insert('INSERT INTO posts (title) VALUES (?)', 'Hello')
DB.get('SELECT * FROM posts WHERE id = ?', id)   # => { 'id' => 1, 'title' => 'Hello', 'body' => nil }