Questions tagged [sequel]

Sequel is a database toolkit for the Ruby programming language that provides abstractions over many SQL RDBMS.

Sequel is a "Database Toolkit for Ruby" that:

  • ...provides thread safety, connection pooling and a concise DSL for constructing SQL queries and table schemas.

  • ...includes a comprehensive ORM layer for mapping records to Ruby objects and handling associated records.

  • ...supports advanced database features such as prepared statements, bound variables, stored procedures, savepoints, two-phase commit, transaction isolation, master/slave configurations, and database sharding.

  • ...has adapters for ADO, Amalgalite, DataObjects, DB2, DBI, Firebird, Informix, JDBC, MySQL, Mysql2, ODBC, OpenBase, Oracle, PostgreSQL, SQLite3, and Swift.

See the documentation for a list of guides, examples, tutorials, and other reference material.

Sequel is currently maintained and primarily developed by Jeremy Evans.

780 questions
5
votes
3 answers

What ORM to use in one process multiple db connections sinatra application?

Checked ActiveRecord, DataMapper, Sequel: some use globals (static variables) some require open db connection before loading source file with models. What ORM is better to use in sinatra application that uses different databases.
Andrey Yatsyk
  • 476
  • 2
  • 8
5
votes
3 answers

Ruby Sequel model to have validation for create and not update

How I can I avoid having validation for update while having it for create? For instance: I wish to have an image field to have presence validation on create. But want to avoid it in edit and assume the previous value in case of no change. Note: I am…
Jikku Jose
  • 18,306
  • 11
  • 41
  • 61
5
votes
2 answers

Boolean combinations of Sequel datasets

Given I have some dataset methods foo, bar and baz class User < Sequel::Model dataset_module do def foo # Some complicated dataset here where(:c => 42, :d => 23) end def bar # Even more complicated dataset here …
iblue
  • 29,609
  • 19
  • 89
  • 128
5
votes
2 answers

How do I create a hstore column in a Sequel migration?

How do I create a hstore column in a Sequel migration? Sequel.migration do change do add_column :logs, :geo, HStore end end fails. Do I have to load an extension?
MegaTux
  • 1,591
  • 21
  • 26
5
votes
2 answers

How to do a Sequel query with 'like'?

I'm trying to implement a form to search through the title of my posts. This is the controller code: post '/search' do @results = Post.all(:Title.like => "%#{params[:query]}%") erb :layout end This is the layout.erb code:
uklp
  • 551
  • 1
  • 6
  • 14
5
votes
2 answers

How to use Sequel to select one field from database

I am using Sinatra and Sequel with PostgreSQL. After authentication, I want to welcome the user by printing their name but I cannot get only the value of the user's name from the database, it comes out as a hash. The query is: current_user =…
user1903663
  • 1,713
  • 2
  • 22
  • 44
5
votes
2 answers

Sequel accessing many_to_many join table when adding association

I'm building a wishlist system using Sequel. I have a wishlists and items table and an items_wishlists join table (that name is what sequel chose). The items_wishlists table also has an extra column for a facebook id (so I can store opengraph…
Tom Brunoli
  • 3,436
  • 9
  • 36
  • 54
5
votes
2 answers

Retrieving nested records in Sequel

I'm trying to retrieve data in a nested form from the following two tables (in SQLite) DB = Sequel.sqlite('database.sqlite') DB.create_table? :artists do primary_key :id String :name end DB.create_table? :albums do …
abhijit
  • 6,363
  • 5
  • 26
  • 32
5
votes
1 answer

Using UNION with Sequel

I want to define a SQL-command like this: SELECT * FROM WOMAN UNION SELECT * FROM MEN I tried to define this with the following code sequence in Ruby + Sequel: require 'sequel' DB = Sequel::Database.new() sel = DB[:women].union(DB[:men]) puts…
knut
  • 27,320
  • 6
  • 84
  • 112
5
votes
1 answer

How can I reload the table schema in sequel?

Given I have the following migration: Sequel.migration do up do alter_table :users do add_column :is_admin, :default => false end # Sequel runs a DESCRIBE table statement, when the model is loaded. # At this point, it does…
iblue
  • 29,609
  • 19
  • 89
  • 128
5
votes
1 answer

Sequel model over two joined tables

I have a legacy PostgreSQL database, which has a single model split into two tables, with one-to-one mapping between them. CREATE TABLE auth_user ( id SERIAL, username VARCHAR(30), email VARCHAR(75), password VARCHAR(64), …
drdaeman
  • 11,159
  • 7
  • 59
  • 104
5
votes
1 answer

Boolean values with SQLite and Sequel

Sequel supports a boolean type. It stores true and false as t and f in SQLite. If you read again, the data are converted back to true and false SQLite itself prefers to store true as 1 and false as 0 (and some SQLite-administartion tools expect…
knut
  • 27,320
  • 6
  • 84
  • 112
4
votes
2 answers

Right place for Sequel DB connection while working on Phusion Passenger with nginx

I have test app written on ruby, using Sinatra+Sequel. config.ru: require './main' run Sinatra::Application Example code: require 'sinatra' require 'haml' require 'sequel' DB=Sequel.connect('oracle://test:test@test') class Tarification <…
Maxim Kachalin
  • 132
  • 1
  • 8
4
votes
3 answers

Sequel Model set_schema not found

Can any one volunteer why the class below fails? ... src/model/user.rb:18: undefined method `set_schema' for User:Class (NoMethodError) I've looked in the Sequel-3.0 lib/ folder and the set_schema method is defined in a ClassMethods module. I'm…
will
  • 4,799
  • 8
  • 54
  • 90
4
votes
1 answer

Ruby EventMachine with PostgreSQL

I know that for mysql em-mysql exists as an asynchronous interface driver to MySQL and that Active Record, with some modification, can make immediate use of. I believe Sequel has this capability already. I also understand that the pg gem exposes…
troutwine
  • 3,721
  • 3
  • 28
  • 62