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
10
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,481
  • 2
  • 17
  • 32
9
votes
2 answers

How to write this better? Ruby Sequel chaining OR

In SQL it should look like this: SELECT * FROM `categories_description_old` WHERE ((`categories_description` = '') OR (`categories_name` = '') OR (`categories_heading_title` = '')) My (ugly) solution: conditions = [:categories_name,…
ipsum
  • 1,042
  • 7
  • 17
9
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
  • 12,096
  • 11
  • 39
  • 49
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
  • 128,308
  • 78
  • 326
  • 506
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
  • 29,609
  • 19
  • 89
  • 128
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,572
  • 3
  • 42
  • 74
8
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
  • 26,856
  • 59
  • 237
  • 450
8
votes
2 answers

Sequel generate migration

I see that the Sequel gem supports migrations here, but I don't see any type of generator documented. Does one exist; or should I be manually creating all of my migrations (or alternately creating my own task to generate migrations)?
bigtunacan
  • 4,873
  • 8
  • 40
  • 73
8
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
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
  • 10,576
  • 7
  • 29
  • 31
7
votes
4 answers

How to correctly load a gem extension in AWS Lambda

I'm having trouble working through a gem load error on AWS Lambda. { "errorMessage": "LoadError: libpq.so.5: cannot open shared object file: No such file or directory - /var/task/vendor/bundle/ruby/2.5.0/gems/pg-1.1.4/lib/pg_ext.so", …
1ijk
  • 1,417
  • 2
  • 19
  • 31
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
  • 6,960
  • 8
  • 45
  • 50
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), …
Maxim 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
  • 28,781
  • 28
  • 95
  • 122
6
votes
2 answers

Sequel query with join and condition on the other table

I'm pretty new to Sequel and I'm scratching my head trying to figure out how to get Sequel's API to generate the following trivial SQL: select f.* from first f join second s on f.second_id = s.id where s.deactivated =…
Krzysztof Kozmic
  • 27,267
  • 12
  • 73
  • 115
1
2
3
51 52