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.

735 questions
9
votes
2 answers

Sequel in conjunction with ActiveRecord any gotchas?

I'm considering using Sequel for some of my hairier SQL that I find too hard to craft in Active Record. Are there any things I need to be aware of when using Sequel and ActiveRecord on the same project? (Besides the obvious ones like no AR…
Sam Saffron
  • 121,058
  • 74
  • 309
  • 495
9
votes
1 answer

default_scope in Sequel

In ActiveRecord there is a default_scope class method to specify a default scope. For example class User < ActiveRecord::Base default_scope where(:deleted => false) end User.all # => SELECT * FROM users WHERE deleted = 0; How can I do this in…
iblue
  • 26,668
  • 17
  • 81
  • 125
9
votes
3 answers

Is it possible to batch updates in Sequel?

Is it possible to make many updates in a single call using Sequel? For instance, making about 200 updates could take several minutes on my server, but if I forge a single SQL query it runs in a matter of seconds. I wonder if Sequel could be used to…
RooSoft
  • 1,359
  • 2
  • 15
  • 27
8
votes
2 answers

Why use SQL builders? Arel v. Sequel v. T-SQL

I'm trying to understand the benefits of building SQL via an object-oriented builder DSL vs. parameterizing a raw SQL string. After researching/implementing the same query three ways, I notice that the raw SQL is by far the easiest to read. This…
Mario
  • 6,206
  • 3
  • 37
  • 69
8
votes
1 answer

How do I define an ARRAY column in a Sequel Postgresql migration?

I am creating a Sequel migration to create a new table in my PostgreSQL database. I want to define a String array column, which PostgreSQL supports. My migration looks like this: create_table :venues do primary_key :id String :reference …
beatlecz
  • 138
  • 1
  • 6
8
votes
2 answers

Sequel -- can I alias subqueries in a join?

Using Sequel I'd like to join two subqueries together that share some column names, and then table-qualify those columns in the select. I understand how to do this if the two datasets are just tables. E.g. if I have a users table and an items…
brahn
  • 11,414
  • 11
  • 36
  • 44
8
votes
2 answers

Unable to connect mysql from Sequel gem

When I try to connect to MySQL from Sequel. I am getting these errors: require 'rubygems' require 'sequel' DB = Sequel.connect(:adapter => 'mysql', :user => 'root', :host => 'localhost', :database => 'scanty',:password=>'xx') …
Subba Rao
  • 9,518
  • 7
  • 26
  • 31
7
votes
2 answers

ruby sequel gem - how to query arrays with the pg_array extension

I am using the pg_array extension and sequel version 4.1.1. I have added the extension like this: Sequel::Database.extension :pg_array I have created a column like this: alter_table :emails do add_column :references, "text[]", null: true end I…
dagda1
  • 21,477
  • 48
  • 188
  • 367
7
votes
3 answers

How can default values in Sequel Models be set?

Given the code below, how can default values be defined for the Model. (let's say the default for :name should be 'Thing'). require 'pp' require 'sequel' DB = Sequel.sqlite DB.create_table :items do primary_key :id String :name end items…
s_2k
7
votes
3 answers

Using UTC with Sequel?

I'd like to not store times in my local timezone, but Sequel is making it really tough on me. I can set them to UTC before I put them in there (a bit of a pain), but then when I take them back out it assumes that they are local dates and then they…
Phil Kulak
  • 5,882
  • 8
  • 40
  • 46
6
votes
2 answers

'Sequel::Error: id is a restricted primary key' when creating record using Sequel

I have a model based on Sequel and Oracle adapter: class Operation < Sequel::Model(DB[:operations]) end If I try to create a record using Oracle's sequence.nextval as primary key: Operation.create( :id=>:nextval.qualify(:Soperations), …
Maksim Kachalin
  • 132
  • 1
  • 8
6
votes
5 answers

How to get rows as Arrays (not Hashes) in Sequel ORM?

In the Sequel ORM for Ruby, the Dataset class has an all method which produces an Array of row hashes: each row is a Hash with column names as keys. For example, given a table T: a b c -------------- 0 22 "Abe" 1 35 "Betty" 2 58 …
jwfearn
  • 26,394
  • 26
  • 89
  • 117
6
votes
3 answers

heroku db:pull not working

heroku db:pull postgresql://root:@localhost/db_name After this command display this message /usr/lib/ruby/gems/1.8/gems/rest-client-1.6.1/lib/restclient/abstract_response.rb:50: warning: parenthesize argument(s) for future version Loaded Taps…
ritesh
  • 61
  • 1
  • 2
6
votes
2 answers

How to pull Heroku data into a local SQLite3 database

I'm trying to make a local backup of the data from my Rails application, which is deployed to Heroku, and running into problems. I followed the taps instructions and installed Taps. I get two types of errors. I created a SQLite DB locally and tried…
kateray
  • 1,808
  • 3
  • 17
  • 23
6
votes
3 answers

Mysql / Ruby Sequel last insert ID value, what method?

I just want to get the last_insert_id() using Ruby's Sequel: insertret = @con.run("INSERT INTO `wv_persons` ( `id` ) VALUES ( NULL )") pp insertret.inspect # returns "nil", expected that.. last_insert_id = @con.run("SELECT LAST_INSERT_ID() AS…
sougonde
  • 3,185
  • 3
  • 23
  • 35
1
2
3
48 49