Skip to content

Instantly share code, notes, and snippets.

@ordinaryzelig
Created October 14, 2013 02:40
Show Gist options
  • Save ordinaryzelig/6969876 to your computer and use it in GitHub Desktop.
Save ordinaryzelig/6969876 to your computer and use it in GitHub Desktop.
require 'sequel'
require 'pg'
db_config = {
adapter: 'postgres',
host: 'localhost',
database: 'asdf',
max_connections: 10,
}
DB = Sequel.postgres(db_config)
# Migration
DB.create_table! :postgres_sequel_models do
primary_key :id
String :name, null: false, unique: true
Integer :idx
end
# Model
class PostgresSequelModel < Sequel::Model
end
PSM = PostgresSequelModel
10.times.map do
Thread.new do
DB.transaction(rollback: :always) do
PSM.new(name: 'name').save
sleep 1
end
end
end.each(&:join)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment